Create backups in backup script
This commit is contained in:
parent
51915829ab
commit
b6532afc9d
3 changed files with 43 additions and 9 deletions
|
|
@ -7,7 +7,11 @@ logInfo() { printf '%(%Y-%m-%d %H:%m:%S)T [INFO]: %s\n' -1 "$*" >&2; }
|
||||||
|
|
||||||
configurationFileLocation=$1
|
configurationFileLocation=$1
|
||||||
|
|
||||||
workDirPath=/root/backup_work_dir
|
# Working on the bulk directory which is mounted on a very big SSD, this way we don't have to wory about
|
||||||
|
# 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...
|
||||||
|
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"
|
||||||
|
|
||||||
|
|
@ -107,9 +111,36 @@ createAllDockerVolumeBackups() {
|
||||||
}
|
}
|
||||||
# endregion: --- DOCKER_VOLUME_BACKUPS ------------------------------------------------------------
|
# endregion: --- DOCKER_VOLUME_BACKUPS ------------------------------------------------------------
|
||||||
|
|
||||||
|
# region: ------ BORG_BACKUPS ---------------------------------------------------------------------
|
||||||
|
createArchiveInRepository() {
|
||||||
|
logInfo "Creating new archive in Borg repository (at $borgRepoDir)..."
|
||||||
|
|
||||||
|
(
|
||||||
|
cd "$workDirPath"
|
||||||
|
|
||||||
|
# Note that BORG_PASSPHRASE is supposed to be set, otherwise a passowrd prompt will be present...
|
||||||
|
borg create --stats --verbose --show-rc --compression zstd,11 \
|
||||||
|
"$borgRepoDir::{fqdn}-{now:%Y-%m-%d}" \
|
||||||
|
./docker_volumes ./postgres
|
||||||
|
|
||||||
|
logInfo "Pruning old backups..."
|
||||||
|
# Copied from: https://borgbackup.readthedocs.io/en/stable/quickstart.html as it seems
|
||||||
|
# like good defaults.
|
||||||
|
borg prune --verbose --glob-archives '{fqdn}-*' --show-rc \
|
||||||
|
--keep-daily 7 --keep-weekly 4 --keep-monthly 6 \
|
||||||
|
"$borgRepoDir"
|
||||||
|
|
||||||
|
logInfo "Compacting repository..."
|
||||||
|
borg compact --verbose --show-rc "$borgRepoDir"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
# endregion: --- BORG_BACKUPS ---------------------------------------------------------------------
|
||||||
|
|
||||||
# region: ------ PREPARE_BACKUP_FILES -------------------------------------------------------------
|
# region: ------ PREPARE_BACKUP_FILES -------------------------------------------------------------
|
||||||
createAllDatabaseBackups
|
createAllDatabaseBackups
|
||||||
echo
|
echo
|
||||||
createAllDockerVolumeBackups
|
createAllDockerVolumeBackups
|
||||||
|
echo
|
||||||
|
# TODO: fetchOldBackupRepositoryFromCloud
|
||||||
|
createArchiveInRepository
|
||||||
# endregion: --- PREPARE_BACKUP_FILES -------------------------------------------------------------
|
# endregion: --- PREPARE_BACKUP_FILES -------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
$ANSIBLE_VAULT;1.1;AES256
|
$ANSIBLE_VAULT;1.1;AES256
|
||||||
34646535396461343238663938663633376230346637306632616463383661613861343831303338
|
37316361316463376662353834626533623465383237343034393765616538313262303031383832
|
||||||
6530366639356331656239303662316131373434333365360a303064623064613461366263613639
|
3833623665663331383131373264366564376539386631320a363861643632663233326564616665
|
||||||
30393537343934613038303263373566333861663061366334313331653934393530333630376338
|
39393161363661373764353534393865663264653861303033373034323836656137303162653631
|
||||||
6236653034303738340a323835383034343132336462363461303463663565326235633461386536
|
3764393530646366330a306338346531663932343531326361613238366434396433623838366334
|
||||||
33303139393736346364636636376632663732313334353132613239383632613761373536643438
|
33636530656466623735346661373130613461616532626430346132303261366133343034336535
|
||||||
36343262343436663866346463393138386437666566353038396432383730366536303763313461
|
64386365303937343637643366356133646434366566373532393431383864663635623164656262
|
||||||
38653735633137303231343864643432666637333065663465363239376333646534333034383535
|
34613562396136616531383461656331383436363461626136396139303263653431626233633438
|
||||||
64336434373339373532
|
36623332376436316236373737613632323630306331316264633432303265343931303034363333
|
||||||
|
65353631316264356530383938636662366637616430336566363063653866333366666131313036
|
||||||
|
3935303838363737303862613161656664666463643137336135
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
pkg:
|
pkg:
|
||||||
- tldr
|
- tldr
|
||||||
|
- tree
|
||||||
- git
|
- git
|
||||||
- vim
|
- vim
|
||||||
- dnsutils
|
- dnsutils
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue