mirror of
https://github.com/turtlebasket/michaelnet.git
synced 2026-03-04 11:34:48 -08:00
backup host -> backup1
This commit is contained in:
30
backup1/README.md
Normal file
30
backup1/README.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# Generic Backup Host
|
||||
|
||||
## Crontab
|
||||
|
||||
Runs on the second of every month.
|
||||
|
||||
```
|
||||
0 0 2 * * cd /home/USER/backups && bash prune.sh
|
||||
```
|
||||
|
||||
## Filename Pattern
|
||||
|
||||
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)
|
||||
```
|
||||
|
||||
Regex to match backups that are *not* from the first of every month, using the above format:
|
||||
|
||||
```
|
||||
[0-9A-Za-z]+-data-[0-9]{4}-[0-9]{2}-([^0][0-9]|[0-9][^1])_.*
|
||||
```
|
||||
|
||||
14
backup1/prune.sh
Normal file
14
backup1/prune.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# 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
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user