Adding forget option for restic.
This commit is contained in:
parent
af731a05e7
commit
671a7ba52a
46
bare.sh
46
bare.sh
|
@ -47,22 +47,25 @@ function usage-repo() {
|
|||
echo " Sharename determined by stripping \$NFS_PREFIX from start of <repopath>."
|
||||
}
|
||||
function usage-rc() {
|
||||
echo " export B2_ACCOUNT_ID=xxx"
|
||||
echo " export B2_ACCOUNT_KEY=xxx"
|
||||
echo " export B2_APP_ID=xxx"
|
||||
echo " export B2_APP_KEY=xxx"
|
||||
echo " export B2_BUCKET_PREFIX=xxx"
|
||||
echo " export RESTIC_PASSWORD=xxx"
|
||||
echo " export RSYNC_SERVER=xxx"
|
||||
echo " export RSYNC_USER=backups"
|
||||
echo " export RSYNC_DIR=/home/backups/backups"
|
||||
echo " export RSYNC_OPTIONS=-Pavz"
|
||||
echo " export KEEPDAYS=31 # days to keep restic backups for"
|
||||
echo " # optional:"
|
||||
echo " #export USMB_PREFIX=/DataVolume/shares"
|
||||
echo " #export NFS_SERVER=nfs.yourdomain.com"
|
||||
echo " #export NFS_SERVER_BASE=/remote/nfs/share/base"
|
||||
echo " #export NFS_PREFIX=/local/nfs/mountpoint"
|
||||
echo " export B2_ACCOUNT_ID=xxx # Backblaze B2 credentials"
|
||||
echo " export B2_ACCOUNT_KEY=xxx # Backblaze B2 credentials"
|
||||
echo " export B2_APP_ID=xxx # Backblaze B2 bucket details"
|
||||
echo " export B2_APP_KEY=xxx # Backblaze B2 bucket auth"
|
||||
echo " export B2_BUCKET_PREFIX=xxx # Prefix to append to create unique B2 bucket name"
|
||||
echo ""
|
||||
echo " export RESTIC_PASSWORD=xxx # Password used to encrypt Restic backups"
|
||||
echo " export RESTIC_KEEPDAYS=31 # Days to keep restic backups for"
|
||||
echo ""
|
||||
echo " export RSYNC_SERVER=xxx # Server used for repos with 'rsync' tag"
|
||||
echo " export RSYNC_USER=backups # Username for rsync server"
|
||||
echo " export RSYNC_DIR=/home/backups/backups # Remote directory on rsync server"
|
||||
echo " export RSYNC_OPTIONS=-Pavz # Options to pass to rsync"
|
||||
echo ""
|
||||
echo " export USMB_PREFIX=/DataVolume/shares # Strip this from repo path to get USMB share name"
|
||||
echo ""
|
||||
echo " export NFS_SERVER=nfs.yourdomain.com # NFS server where local files for 'nfs' repos are found"
|
||||
echo " export NFS_SERVER_BASE=/remote/nfs/share/base # Path on local NFS server to prefix to repo names"
|
||||
echo " export NFS_PREFIX=/local/nfs/mountpoint # Where to mount NFS exports locally before backing them up"
|
||||
}
|
||||
|
||||
function usage() {
|
||||
|
@ -195,8 +198,8 @@ if [[ -z $B2_APP_KEY ]]; then
|
|||
echo "Error - \$B2_APP_KEY not set."
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z $KEEPFOR ]]; then
|
||||
echo "Error - \$KEEPFOR not set."
|
||||
if [[ -z $RESTIC_KEEPDAYS ]]; then
|
||||
echo "Error - \$RESTIC_KEEPDAYS not set."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -484,9 +487,10 @@ for f in $REPOSTOBACKUP; do
|
|||
${RESTIC} init $AUTHOPTS $CONNECTIONSOPTS >/dev/null 2>&1
|
||||
fi
|
||||
elif [[ $CMD == "forget" ]]; then
|
||||
# age out stuff after xxx days
|
||||
FORGETOPTS="-d ${KEEPDAYS} --prune"
|
||||
${RESTIC} forget $AUTHOPTS $CONNECTIONSOPTS $FORGETOPTS 2>&1 >> ${LOG}
|
||||
# age out stuff after RESTIC_KEEPDAYS days
|
||||
FORGETOPTS="-d ${RESTIC_KEEPDAYS}"
|
||||
${RESTIC} forget $AUTHOPTS $CONNECTIONSOPTS $FORGETOPTS 2>&1 | awk '($1 == "Applying") { print } ($2 == "snapshots") { show=0 } (show == 1 && $1 != "ID" && NF > 1) { print "Removing: " $0 } ($1 == "remove") { show=1 }' >> ${LOG}
|
||||
${RESTIC} prune $AUTHOPTS 2>&1 | egrep "^(repository contain|found|will|remove)" >> ${LOG}
|
||||
else
|
||||
log "Error: invalid command $CMD"
|
||||
rv=0
|
||||
|
|
Loading…
Reference in New Issue