Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Keep N backups #8

Open
Gr4ffy opened this issue Mar 9, 2023 · 9 comments
Open

[Feature Request] Keep N backups #8

Gr4ffy opened this issue Mar 9, 2023 · 9 comments

Comments

@Gr4ffy
Copy link

Gr4ffy commented Mar 9, 2023

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"

@Akirainblack
Copy link

I'd like to +1 this.

@yolani
Copy link

yolani commented Mar 13, 2023

+1

@federicofortini
Copy link

I also would love to have that feature

@poudenes
Copy link

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

@francoisneveux
Copy link

+1

1 similar comment
@truefoobar
Copy link

+1

@ameer1234567890
Copy link

+1

@federicofortini
Copy link

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

@mzeecedric
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

9 participants