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

optionally delete old backups #188

Merged
merged 6 commits into from
Jan 29, 2024
Merged

optionally delete old backups #188

merged 6 commits into from
Jan 29, 2024

Conversation

sugoidogo
Copy link
Contributor

@sugoidogo sugoidogo commented Jan 28, 2024

Context

Optionally delete old backups when creating new ones, to prevent infinitely growing size of backup folder with automatic backups, such as when using cron to run the backup script

Choices

With the find command, you can filter for old files, print the file names, and delete them all at once. I also had previous backups of my own that I moved into the backup directory, which are folders instead of files, but will still be deleted by this command once their retention age has passed.

Test instructions

Create a backup, change time past retention time, create another backup, run find command

[sugoidogo@imac2 backups]$ sudo podman exec palworld backup
Complete Save
backup created at /palworld/backups/palworld-save-2024-01-28_11-04-01.tar.gz
[sugoidogo@imac2 backups]$ touch -d "1 year ago" palworld-save*
[sugoidogo@imac2 backups]$ sudo podman exec palworld backup
Complete Save
backup created at /palworld/backups/palworld-save-2024-01-28_11-09-11.tar.gz
[sugoidogo@imac2 backups]$ ls -l
total 1677852
-rw-r--r-- 1 sugoidogo sugoidogo 859054235 Jan 28  2023 palworld-save-2024-01-28_11-04-01.tar.gz
-rw-r--r-- 1 sugoidogo sugoidogo 859052913 Jan 28 11:09 palworld-save-2024-01-28_11-09-11.tar.gz
[sugoidogo@imac2 backups]$ find /opt/palworld/backups/ -mindepth 1 -maxdepth 1 -mtime +30 -print -delete
/opt/palworld/backups/palworld-save-2024-01-28_11-04-01.tar.gz
[sugoidogo@imac2 backups]$ ls -l
total 838924
-rw-r--r-- 1 sugoidogo sugoidogo 859052913 Jan 28 11:09 palworld-save-2024-01-28_11-09-11.tar.gz

Checklist before requesting a review

  • I have performed a self-review of my code
  • I've added documentation about this change to the README.
  • I've not introduced breaking changes.

@thijsvanloef thijsvanloef added the enhancement New feature or request label Jan 28, 2024
@Dashboy1998 Dashboy1998 mentioned this pull request Jan 29, 2024
3 tasks
scripts/backup.sh Outdated Show resolved Hide resolved
@thijsvanloef thijsvanloef merged commit 3204bc6 into thijsvanloef:main Jan 29, 2024
4 checks passed
MusclePr pushed a commit to MusclePr/palworld-server-docker that referenced this pull request Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants