simplify borg sync script

This commit is contained in:
Gabriel Augendre 2024-10-15 18:32:42 +02:00
parent d2417fc187
commit ce7db9a8e6

View file

@ -4,11 +4,7 @@
SOURCE_DIRECTORY="/mnt/data/nextcloud-aio/backups/borg"
RCLONE_CONFIG="borgbase-nextcloud-aio"
TARGET_DIRECTORY="repo" # this is the BorgBase directory name: modify it only if you want to specify a different one (discouraged)
########################################
# DO NOT modify any of the following! #
########################################
TARGET_DIRECTORY="repo"
if [ "$EUID" -ne 0 ]; then
echo "run as root"
@ -39,19 +35,11 @@ touch "$SOURCE_DIRECTORY/aio-lockfile"
if ! rclone sync -v --exclude aio-lockfile "$SOURCE_DIRECTORY/" "$RCLONE_CONFIG:$TARGET_DIRECTORY"; then
if docker ps --format "{{.Names}}" | grep "^nextcloud-aio-nextcloud$"; then
docker exec -en nextcloud-aio-nextcloud bash /notify.sh "Rclone failed." "Failed to synchronise the backup repository with the target directory."
else
echo "Failed to synchronise the backup repository with the target directory."
fi
rm "$SOURCE_DIRECTORY/aio-lockfile"
exit 1
fi
rm "$SOURCE_DIRECTORY/aio-lockfile"
if docker ps --format "{{.Names}}" | grep "^nextcloud-aio-nextcloud$"; then
docker exec -en nextcloud-aio-nextcloud bash /notify.sh "Rclone backup successful!" "Synchronised the backup repository successfully."
else
echo "Synchronised the backup repository successfully."
fi
echo "Done"