portainer-backup
portainer-backup copied to clipboard
[Feature Request] Keep N backups
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"
I'd like to +1 this.
+1
I also would love to have that feature
This would be great to have keep_days. Love the tool to backup my whole Portainer!
+1
+1
+1
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:
-
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