feat: debian package
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
Package: autobackup
|
||||
Version: 1.0
|
||||
Architecture: all
|
||||
Maintainer: zankia <admin@zankia.fr>
|
||||
Description: automatically backup directories on a regular basis
|
||||
Depends: bash, findutils, rsync
|
||||
@@ -0,0 +1 @@
|
||||
# Mettre ici tous les dossiers à sauvegarder. Un dossier par ligne
|
||||
@@ -0,0 +1,2 @@
|
||||
BACKUP_DIR="/backup"
|
||||
RETENTION_DAYS=364
|
||||
@@ -0,0 +1,2 @@
|
||||
# Automatically backup directories on a daily basis
|
||||
0 4 * * * root /usr/bin/autobackup
|
||||
Executable
+39
@@ -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 {} \;
|
||||
Reference in New Issue
Block a user