diff --git a/btrbk b/btrbk index ce2a65d..78e1f22 100755 --- a/btrbk +++ b/btrbk @@ -170,11 +170,17 @@ function testConf { } function testDate { - if [ `date +%d` != "01" ]; then - bkRun "incremental" - else - bkRun "full" + if [ $BKCYCLE = "weekly" ]; then + local dateType = "+%u" + elif [ $BKCYCLE = "monthly" ]; then + local dateType = "+%d" fi + for i in ${!BKRETENTION[@]}; do + if [ `date $dateType` = ${BKRETENTION[$i]} ]; then + bkRun "full" + fi + done + bkRun "incremental" } function end { @@ -196,7 +202,7 @@ function echoHelp { exit 1 } -options=$(getopt -l "backup,force,date::,restore::,full-restore::,help" -o "bfd::r::x::h" -- "$@") +options=$(getopt -l "backup,force,date::,restore::,full-restore::,help" -o "bfx::h" -- "$@") eval set -- "$options" for i in ${!options[@]}; do case $1 in diff --git a/btrbk.conf b/btrbk.conf index 07479bd..6e716c1 100644 --- a/btrbk.conf +++ b/btrbk.conf @@ -22,6 +22,15 @@ RCLONEDIR="test:/mnt/bk/new/" #How many local snapshots should be kept KEEPLOCAL="10" +#How often to run a full backup: "monthly" or "weekly" +BKCYCLE="monthly" + +#Day when to run full Backup +#can be specified multiple times 1-7 for weekely and 01-30 for monthly +#example ("01" "05" "23") +BKRETENTION=("01") + + #Suffix name for incremental/full backups and retention #example: [YYYY-mm-"full"] and will keep the last two backups #For full Backups dont set retention below 1 or you will always delete your current backup which renders all following incremental backups useless