portainer-backup icon indicating copy to clipboard operation
portainer-backup copied to clipboard

[Feature Request] Keep N backups

Open Gr4ffy opened this issue 1 year ago • 9 comments

Thank you for your work and your time.

It would be nice to have an option to keep only specified number of backups. To use with: --filename "portainer-backup-{{DATE}}.tar.gz"

Gr4ffy avatar Mar 09 '23 10:03 Gr4ffy

I'd like to +1 this.

Akirainblack avatar Mar 09 '23 18:03 Akirainblack

+1

yolani avatar Mar 13 '23 06:03 yolani

I also would love to have that feature

federicofortini avatar Mar 22 '23 10:03 federicofortini

This would be great to have keep_days. Love the tool to backup my whole Portainer!

poudenes avatar Jul 27 '23 08:07 poudenes

+1

francoisneveux avatar Aug 11 '23 19:08 francoisneveux

+1

truefoobar avatar Aug 31 '23 12:08 truefoobar

+1

ameer1234567890 avatar Nov 05 '23 18:11 ameer1234567890

I suggest to use this container, combined with portainer-backup: https://github.com/Glideh/docker-cron-rotate-backups It help me with all the varius backup.

Ecample of docker-compose,yml

rotate-portainer-backup: image: glide/cron-rotate-backups:0.1 container_name: portainer-backup-rotate restart: unless-stopped network_mode: none volumes: - :/data environment: ROTATE_CRON: "0 0 * * *" # Daily at midnight i'll do the cleanup ROTATE_OPTIONS: "--daily=7 --weekly=4 --monthly=12 --yearly=2" # to test the rotation settings tou could add --dry-run

federicofortini avatar Nov 06 '23 10:11 federicofortini

As a workaround I simply run the backup within the following bash script. It generates backup-files with a name including weekdays and on every Friday with the name of the month. so I have a backup of 7 days and then 12 months back. A cronjob runs the script every night.

#!/bin/bash
#
# Runs a backup of portainer with 
# the docker container by savagesoftware/portainer-backup 
#
# SETUP
backup_dir=/mnt/backup/portainer
pt_url="http://portainer:9000"
# create a portainer access token at "User settings>Add access token"
pt_token="YOURTOKEN"
# END SETUP

# Create backup directory 
if [ ! -d $backup_dir ]; then
        mkdir -p $backup_dir
fi

# Timestamp for backup
# save with full date every friday
if [ `date "+%w"` = "5" ]; then
        date=`date "+%B"`
else
        date=`date "+%A"`
fi

# Run docker container
docker run -i --rm \
  --name portainer-backup \
  --network npm_network \
  --volume $backup_dir:/backup \
  --env TZ="Europe/Berlin" \
  --env PORTAINER_BACKUP_URL="$pt_url" \
  --env PORTAINER_BACKUP_TOKEN="$pt_token" \
  --env PORTAINER_BACKUP_OVERWRITE=true  \
  --env PORTAINER_BACKUP_DIRECTORY=/backup \
  --env PORTAINER_BACKUP_FILENAME=portainer_$date.tgz \
  --env PORTAINER_BACKUP_QUIET=1 \
  --env PORTAINER_BACKUP_CONCISE=0 \
  savagesoftware/portainer-backup:latest \
  backup

mzeecedric avatar Feb 08 '24 23:02 mzeecedric