dda-backup/infrastrucure/docker/image/resources/file-functions.sh

34 lines
1 KiB
Bash
Raw Normal View History

2020-12-31 14:05:56 +00:00
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
}
2020-12-31 14:05:56 +00:00
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}
}