Skip to content
Snippets Groups Projects
Commit 2d431342 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

add param prune and help in transfer.sh

parent c0cb0094
No related branches found
No related tags found
1 merge request!18add param prune and help in transfer.sh
......@@ -49,7 +49,7 @@ RESTIC
* encrypts data
* deduplicates files
* delete backups by rules to keep a count of hourly, daily, weekly, mothly, yearly backups
* several backup targets (we currently use sftp:// http:// and file://)
* several backup targets (we currently use sftp:// https:// and file://)
### control simoultanous backups ###
......@@ -186,10 +186,66 @@ TODO: advanced stuff ... There is a possibility for directory based include and
### Setup the target ###
incl. test transfer to storage
Edit **jobs/transfer.job**. This file handles the transfer of local directories
to a backup target. You find comments in the config.
By default the backp tool "restic" is activated (and recommended). You can switch to duplicity
if you feel familiar with it.
`bin = restic`
Create a repository base directory with the wanted protocol. This step has to be done
once for all systems you want to backup. The IML Backup will create a subdirectory
with the hostname for its backups. Set your target in storage:
`storage = sftp://backup@storage.example.com//netshare/backup`
## Production usage ##
Edit **jobs/transfer.job**.
Set a password to encrypt local data with it. Each system should have its own password.
Use a long password - i.e. 128 characters.
Save your password list - if you loose it you cannot restore data anymore.
`passphrase = EnterYourSecretHere`
Change the restore path if needed. A restore does not overwrite the current files.
`restore-path = /restore`
Then have a look to the section with variables that have the prefix of bin = ... (restic_... or duplicity_...).
The index files are stored in $HOME. Because /root partition could be to small for
systems with many files (fileserver) you can put the index somewhere else:
`*_cachedir = ...`
With this loglevel you get a list of new or changed files in the log:
`restic_verbose = 2`
You can set a tag that is set for backups by script.
`restic_tag = imlbackup`
The mount of backup sets is a restic feature. After mounting a backup there
you can browse via filesystem through backups and timestamps.
`restic_mountpoint = /mnt/restore`
Define how many backups you wanto to keep. After the backup of a directory
the cleanup strategy will be applied.
```
# prune
restic_keep-hourly = 100
restic_keep-daily = 90
restic_keep-weekly = 12
restic_keep-monthly = 12
restic_keep-yearly = 10
```
### setup backup times ###
### Create a cronjob ###
......
......@@ -7,6 +7,8 @@
# transfer.sh - incremental backup
# transfer.sh full - full backup
# transfer.sh dumps - transfer local dumps only
# transfer.sh prune - cleanup backup data
# transfer.sh help - show help
#
# --------------------------------------------------------------------------------
# ah - Axel Hahn <axel.hahn@iml.unibe.ch>
......@@ -26,6 +28,7 @@
# 2020-02-25 ah,ds, v1.11 fix test -z with non existing vars; show final backup status
# 2021-01-29 ah,ds, v1.12 abort on empty passphrase
# 2021-05-19 ah,ds, v2.0 plugin driven to support multiple backup tools (duplicity + restic)
# 2021-12-02 ah v2.1 added parameter "prune" to cleanup only
# ================================================================================
......@@ -39,6 +42,9 @@
. `dirname $0`/inc_bash.sh
typeset -i rc=0
typeset -i doBackup=1
typeset -i doPrune=1
if [ ! -r "${DIRFILE}" -o ! -r "${STORAGEFILE}" ]; then
echo "SKIP backup of local files - one of the files is not readable (no error): ${DIRFILE} | ${STORAGEFILE}"
exit 0
......@@ -104,7 +110,26 @@
# MAIN
# --------------------------------------------------------------------------------
if [ "$1" = "help" -o "$1" = "-h" -o "$1" = "-?" ]; then
echo "HELP:
Transfer local files to a backup target.
target ${STORAGE_BASEDIR}
backup tool $STORAGE_BIN
PARAMETERS:
transfer.sh - incremental backup
transfer.sh full - full backup
transfer.sh dumps - transfer local dumps only
transfer.sh prune - cleanup backup data only (no backup)
transfer.sh help - show this help (works with -h and -? too)
"
exit 0
fi
if [ "$1" = "prune" ]; then
doBackup=0
fi
h1 `date` TRANSFER LOCAL DATA TO STORAGE | tee -a $transferlog
......@@ -269,7 +294,9 @@
# --- backup
h3 "`date` Backup ${mydir}"
if [ $doBackup -eq 0 ]; then
echo "SKIP backup"
else
sCmd="$( t_backupDirGetCmdBackup )"
echo "what: ${mydir}"
echo "target: ${sTarget}"
......@@ -292,13 +319,18 @@
echo DIR OK ${mydir} was successful.
fi
color reset
fi
echo
# --- post action
h3 "`date` POST backup task for ${mydir}"
if [ $doPrune -eq 0 ]; then
echo "SKIP prune"
else
t_backupDirDoPostTasks
echo
fi
echo
else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment