backup changes
parent
f0f9ab7800
commit
1ae8b3160d
|
@ -1,5 +1,13 @@
|
||||||
# Generic Backup Host
|
# Generic Backup Host
|
||||||
|
|
||||||
|
## Crontab
|
||||||
|
|
||||||
|
Runs on the second of every month.
|
||||||
|
|
||||||
|
```
|
||||||
|
0 0 2 * * cd /home/USER/backups && bash prune.sh
|
||||||
|
```
|
||||||
|
|
||||||
## Filenames
|
## Filenames
|
||||||
|
|
||||||
Container volume backups are of the format:
|
Container volume backups are of the format:
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
#!/usr/bin/bash
|
#!/usr/bin/bash
|
||||||
|
|
||||||
# Prunes container data folders monthly on backup host
|
# Prunes container data folders monthly on backup host.
|
||||||
# - Regex has been tested and works
|
# Removes all items but the backup from the first day of the month.
|
||||||
# - Script is not yet tested
|
# 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 item in *; do
|
||||||
|
if [[ "$item" =~ [0-9A-Za-z]+-data-[0-9]{4}-[0-9]{2}-([^0][0-9]|[0-9][^1])_.* ]]; then
|
||||||
for archive in $ARCHIVES; do
|
echo "Removing $item"
|
||||||
if [ -d $archive ]; then
|
rm -f $item
|
||||||
echo "Removing $archive"
|
|
||||||
rm -f $archive
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue