dda-backup/infrastructure/docker/image/resources/file-functions.sh
2021-03-01 11:54:42 +01:00

34 lines
No EOL
1 KiB
Bash

function init-file-repo() {
restic -r ${RESTIC_REPOSITORY}/files -v init
}
function backup-directory() {
local directory="$1"; shift
restic -v -r ${RESTIC_REPOSITORY}/files unlock --cleanup-cache
cd ${directory} && restic -v -r ${RESTIC_REPOSITORY}/files backup .
restic -v -r ${RESTIC_REPOSITORY}/files forget --keep-last 1 --keep-within ${RESTIC_DAYS_TO_KEEP}d --prune
}
# First arg is the directory, the remaining args are the sub-directories (relative to the first directory) to backup.
function backup-fs-from-directory() {
local directory="$1"; shift
restic -v -r ${RESTIC_REPOSITORY}/files unlock --cleanup-cache
cd ${directory} && restic -v -r ${RESTIC_REPOSITORY}/files backup $@
restic -v -r ${RESTIC_REPOSITORY}/files forget --keep-last 1 --keep-within ${RESTIC_DAYS_TO_KEEP}d --prune
}
function restore-directory() {
local directory="$1"; shift
restic -v -r ${RESTIC_REPOSITORY}/files unlock --cleanup-cache
rm -rf ${directory}*
restic -v -r $RESTIC_REPOSITORY/files restore latest --target ${directory}
}