Vault warden and backup
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
FROM alpine:latest
|
||||
RUN apk add --no-cache rsync tzdata
|
||||
|
||||
COPY backup.sh /usr/local/bin/backup.sh
|
||||
RUN chmod +x /usr/local/bin/backup.sh
|
||||
|
||||
CMD ["crond", "-f", "-l", "2"]
|
||||
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Format the current date
|
||||
NOW=$(date +"%Y-%m-%d")
|
||||
|
||||
# Create the archive directory if it does not exist
|
||||
mkdir -p /backup/archive
|
||||
|
||||
# Run rsync with an exclude file and a backup directory for changed/deleted files
|
||||
rsync -av --delete \
|
||||
--exclude-from=/config/exclude.txt \
|
||||
--backup --backup-dir=/backup/archive/$NOW \
|
||||
/data/ /backup/latest/
|
||||
|
||||
# Find and delete archive directories older than 7 days
|
||||
find /backup/archive/ -mindepth 1 -maxdepth 1 -type d -mtime +7 -exec rm -rf {} +
|
||||
@@ -0,0 +1,2 @@
|
||||
# Run the backup every day at 2:00 AM
|
||||
0 2 * * * /usr/local/bin/backup.sh
|
||||
@@ -0,0 +1,4 @@
|
||||
*.log
|
||||
.backups
|
||||
.DS_Store
|
||||
._*
|
||||
Reference in New Issue
Block a user