mirror of
https://github.com/nextcloud/all-in-one.git
synced 2024-12-27 01:02:10 +08:00
allow to lock the backup archive for external scripts
Signed-off-by: szaimen <szaimen@e.mail.de>
This commit is contained in:
parent
3c14cc2676
commit
b5d5b1f4bc
2 changed files with 17 additions and 2 deletions
|
@ -37,6 +37,13 @@ if [ "$BORG_MODE" != backup ] && [ "$BORG_MODE" != test ] && ! [ -f "$BORG_BACKU
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Do not continue if this file exists (needed for simple external blocking)
|
||||
if [ -f "$BORG_BACKUP_DIRECTORY/aio-lockfile" ]; then
|
||||
echo "Not continuing because aio-lockfile exists - it seems like a script is externally running which is locking the backup archive."
|
||||
echo "If this should not be the case, you can fix this by deleting the 'aio-lockfile' file from the backup archive directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create lockfile
|
||||
if [ "$BORG_MODE" = backup ] || [ "$BORG_MODE" = restore ]; then
|
||||
touch "/nextcloud_aio_volumes/nextcloud_aio_database_dump/backup-is-running"
|
||||
|
|
12
readme.md
12
readme.md
|
@ -293,11 +293,21 @@ if ! [ -d "$TARGET_DIRECTORY" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f "$SOURCE_DIRECTORY/aio-lockfile" ]; then
|
||||
echo "Not continuing because aio-lockfile already exists."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
touch "$SOURCE_DIRECTORY/aio-lockfile"
|
||||
|
||||
if ! rsync --stats --archive --human-readable --delete "$SOURCE_DIRECTORY/" "$TARGET_DIRECTORY"; then
|
||||
echo "Failed to sync the backup repository to the target directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm "$SOURCE_DIRECTORY/aio-lockfile"
|
||||
rm "$TARGET_DIRECTORY/aio-lockfile"
|
||||
|
||||
umount "$DRIVE_MOUNTPOINT"
|
||||
|
||||
if docker ps --format "{{.Names}}" | grep "^nextcloud-aio-nextcloud$"; then
|
||||
|
@ -317,8 +327,6 @@ Afterwards apply the correct permissions with `sudo chown root:root /root/backup
|
|||
1. Add the following new line to the crontab if not already present: `0 20 * * 7 /root/backup-script.sh` which will run the script at 20:00 on Sundays each week.
|
||||
1. save and close the crontab (when using nano are the shortcuts for this `Ctrl + o` -> `Enter` and close the editor with `Ctrl + x`).
|
||||
|
||||
⚠️ **Attention:** Make sure that the execution of the script does not collide with the daily backups from AIO (if configured) since the target backup repository might get into an inconsistent state. (There is no check in place that checks this.)
|
||||
|
||||
### How to change the default location of Nextcloud's Datadir?
|
||||
You can configure the Nextcloud container to use a specific directory on your host as data directory. You can do so by adding the environmental variable `NEXTCLOUD_DATADIR` to the initial startup of the mastercontainer. Allowed values for that variable are strings that start with `/` and are not equal to `/`.
|
||||
|
||||
|
|
Loading…
Reference in a new issue