backup changes

master
michael 2023-07-27 23:45:33 -07:00
parent f0f9ab7800
commit 1ae8b3160d
2 changed files with 16 additions and 9 deletions

View File

@ -1,5 +1,13 @@
# Generic Backup Host
## Crontab
Runs on the second of every month.
```
0 0 2 * * cd /home/USER/backups && bash prune.sh
```
## Filenames
Container volume backups are of the format:

View File

@ -1,15 +1,14 @@
#!/usr/bin/bash
# Prunes container data folders monthly on backup host
# - Regex has been tested and works
# - Script is not yet tested
# Prunes container data folders monthly on backup host.
# Removes all items but the backup from the first day of the month.
# Should run on the first day of every month - since it doesn't remove the backup
# from that time, it doesn't matter what time it's run
ARCHIVES=$(ls | grep -E "[0-9A-Za-z]+-data-\d{4}-\d{2}-([^0][0-9]|[0-9][^1])_.*")
for archive in $ARCHIVES; do
if [ -d $archive ]; then
echo "Removing $archive"
rm -f $archive
for item in *; do
if [[ "$item" =~ [0-9A-Za-z]+-data-[0-9]{4}-[0-9]{2}-([^0][0-9]|[0-9][^1])_.* ]]; then
echo "Removing $item"
rm -f $item
fi
done