Finish backup script with remote repo
This commit is contained in:
parent
b6532afc9d
commit
3c0ea05f5c
1 changed files with 9 additions and 12 deletions
|
|
@ -11,16 +11,15 @@ configurationFileLocation=$1
|
||||||
# running out of disk space. Note however that borg specifically might make use of cache directories
|
# running out of disk space. Note however that borg specifically might make use of cache directories
|
||||||
# in the home directory which aren't on this disk, let's tackle this problem when it actually starts failing...
|
# in the home directory which aren't on this disk, let's tackle this problem when it actually starts failing...
|
||||||
workDirPath=/bulk/backup_work_dir
|
workDirPath=/bulk/backup_work_dir
|
||||||
borgRepoDir="$workDirPath/borg_backups" # Used throughout the script
|
|
||||||
logInfo "Creating working directory at: $workDirPath..."
|
logInfo "Creating working directory at: $workDirPath..."
|
||||||
mkdir -p "$workDirPath"
|
mkdir -p "$workDirPath"
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
logInfo "Backup interrupted"
|
logInfo "Removing working directory at: $workDirPath..."
|
||||||
# rm -f "$workDirPath" # TODO: Enable
|
rm -rf "$workDirPath"
|
||||||
exit 2
|
|
||||||
}
|
}
|
||||||
trap 'cleanup' INT TERM
|
trap 'logInfo "Backup interrupted"; cleanup; exit 2' INT TERM
|
||||||
|
trap 'logInfo "Backup completed, cleaning up..."; cleanup' EXIT
|
||||||
|
|
||||||
# region: ------ DB_BACKUPS -----------------------------------------------------------------------
|
# region: ------ DB_BACKUPS -----------------------------------------------------------------------
|
||||||
createDatabaseBackup() {
|
createDatabaseBackup() {
|
||||||
|
|
@ -113,25 +112,24 @@ createAllDockerVolumeBackups() {
|
||||||
|
|
||||||
# region: ------ BORG_BACKUPS ---------------------------------------------------------------------
|
# region: ------ BORG_BACKUPS ---------------------------------------------------------------------
|
||||||
createArchiveInRepository() {
|
createArchiveInRepository() {
|
||||||
logInfo "Creating new archive in Borg repository (at $borgRepoDir)..."
|
logInfo "Creating new archive in Borg repository (at $BORG_REPO)..."
|
||||||
|
|
||||||
(
|
(
|
||||||
cd "$workDirPath"
|
cd "$workDirPath"
|
||||||
|
|
||||||
# Note that BORG_PASSPHRASE is supposed to be set, otherwise a passowrd prompt will be present...
|
# Note that both BORG_PASSPHRASE and BORG_REPO should be set, otherwise a password prompt will be present...
|
||||||
borg create --stats --verbose --show-rc --compression zstd,11 \
|
borg create --stats --verbose --show-rc --compression zstd,11 \
|
||||||
"$borgRepoDir::{fqdn}-{now:%Y-%m-%d}" \
|
"::{fqdn}-{now:%Y-%m-%d}" \
|
||||||
./docker_volumes ./postgres
|
./docker_volumes ./postgres
|
||||||
|
|
||||||
logInfo "Pruning old backups..."
|
logInfo "Pruning old backups..."
|
||||||
# Copied from: https://borgbackup.readthedocs.io/en/stable/quickstart.html as it seems
|
# Copied from: https://borgbackup.readthedocs.io/en/stable/quickstart.html as it seems
|
||||||
# like good defaults.
|
# like good defaults.
|
||||||
borg prune --verbose --glob-archives '{fqdn}-*' --show-rc \
|
borg prune --verbose --glob-archives '{fqdn}-*' --show-rc \
|
||||||
--keep-daily 7 --keep-weekly 4 --keep-monthly 6 \
|
--keep-daily 7 --keep-weekly 4 --keep-monthly 6
|
||||||
"$borgRepoDir"
|
|
||||||
|
|
||||||
logInfo "Compacting repository..."
|
logInfo "Compacting repository..."
|
||||||
borg compact --verbose --show-rc "$borgRepoDir"
|
borg compact --verbose --show-rc
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
# endregion: --- BORG_BACKUPS ---------------------------------------------------------------------
|
# endregion: --- BORG_BACKUPS ---------------------------------------------------------------------
|
||||||
|
|
@ -141,6 +139,5 @@ createAllDatabaseBackups
|
||||||
echo
|
echo
|
||||||
createAllDockerVolumeBackups
|
createAllDockerVolumeBackups
|
||||||
echo
|
echo
|
||||||
# TODO: fetchOldBackupRepositoryFromCloud
|
|
||||||
createArchiveInRepository
|
createArchiveInRepository
|
||||||
# endregion: --- PREPARE_BACKUP_FILES -------------------------------------------------------------
|
# endregion: --- PREPARE_BACKUP_FILES -------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue