backup host + tweaks

This commit is contained in:
2023-06-25 09:25:32 -07:00
parent 0a786395ec
commit f0f9ab7800
3 changed files with 66 additions and 11 deletions

24
backup/README.md Normal file
View File

@@ -0,0 +1,24 @@
# Generic Backup Host
## Filenames
Container volume backups are of the format:
```
gitea-data-2023-06-17_050002.tar.gz.enc
^ ^ ^
| | Backups are encrypted tarballs
| |
| ISO Datetime separated by _
|
Container volume name (*-data)
```
## Matching
Regex to match backups that are *not* from the first of every month:
```
.*-data-\d{4}-\d{2}-([^0][0-9]|[0-9][^1])_.*
```

15
backup/prune.sh Normal file
View File

@@ -0,0 +1,15 @@
#!/usr/bin/bash
# Prunes container data folders monthly on backup host
# - Regex has been tested and works
# - Script is not yet tested
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
fi
done