feat: debian package

This commit is contained in:
2024-02-19 00:02:21 +01:00
parent 1abf28cdf5
commit d658010ae8
7 changed files with 30 additions and 2 deletions
+39
View File
@@ -0,0 +1,39 @@
#! /bin/bash
if [ -f config.properties ]; then
source config.properties
elif [ -f /etc/autoBackup/config.properties ]; then
source /etc/autoBackup/config.properties
else
>&2 echo Could not find config.properties
exit 1
fi
if [ -f backup.list ]; then
SOURCE_LIST_FILE=backup.list
elif [ -f /etc/autoBackup/backup.list ]; then
SOURCE_LIST_FILE=/etc/autoBackup/backup.list
else
>&2 echo Could not find backup.list
exit 1
fi
mkdir -p "$BACKUP_DIR"
DATE=$(date "+%Y%m%d")
while IFS= read -r SOURCE; do
SOURCE="${SOURCE%%#*}"
SOURCE=$(echo "$SOURCE" | sed -re 's/^[[:blank:]]+|[[:blank:]]+$//g')
if [ -z "$SOURCE" ]; then
continue
fi
rsync --archive --relative --link-dest="$BACKUP_DIR/previous" "$SOURCE" "$BACKUP_DIR/backup_$DATE"
done <"$SOURCE_LIST_FILE"
rm "$BACKUP_DIR/previous"
ln -s "backup_$DATE" "$BACKUP_DIR/previous"
find "$BACKUP_DIR" -maxdepth 1 -type d -mtime "+$RETENTION_DAYS" -exec rm -r {} \;