fix: fix weekly backup

This commit is contained in:
Shannon Sterz 2018-03-18 11:48:57 +01:00
parent 9d62432ab9
commit 7ff771ce13
Signed by: sterzy
GPG key ID: DAE2BE6432FB782A
2 changed files with 6 additions and 3 deletions

View file

@ -52,6 +52,9 @@ FROMSSHUSER="" # The ssh user of the system from which the
# files will be backed up
FROMSSHPORT=22 # The ssh port of the system from which the
# files will be backed up
WEEKS=5 # For how many weeks shall we save backups?
# This will keep weekly backups for at most 5
# weeks.
```
### Crontab example

View file

@ -25,11 +25,11 @@ FROMSSHUSER="" # The ssh user of the system from which the
# files will be backed up
FROMSSHPORT=22 # The ssh port of the system from which the
# files will be backed up
WEEKS=5 # For how many weeks shall we save backups?
## Command variables,
# These should be fine, but if something doesn't work these can be adjusted
MOUNT="/bin/mount"; FGREP="/bin/fgrep"; SSH="/usr/bin/ssh"
MOUNT="/bin/mount"; FGREP="/bin/fgrep"; SSH="/usr/bin/ssh"; EXPR="/usr/bin/expr"
LN="/bin/ln"; ECHO="/bin/echo"; DATE="/bin/date"; MKDIR="/bin/mkdir"
DPKG="/usr/bin/dpkg"; AWK="/usr/bin/awk"; MAIL="/usr/bin/mail"
CUT="/usr/bin/cut"; TR="/usr/bin/tr"; RSYNC="/usr/bin/rsync"
@ -139,6 +139,7 @@ WEEKDAY=$($DATE +"%u") # %a = weekday as number
DAY=$($DATE +"%d") # %d = day in month as number
MONTH=$($DATE +%m) # %m = month as number
HOUR=$($DATE +"%H") # %H = hour as number
WEEK=$($EXPR $($DATE +"%W") % $WEEKS) # %W = week as number, used to save backups for the past $WEEKS weeks
# Create a backup every first day in a month
if [[ $DAY = 01 ]]; then
@ -147,7 +148,6 @@ fi
# Create a special backup approx every week
if [[ $WEEKDAY = 7 ]]; then
let WEEK=$($DATE +"%W")%5 # save past 5 weeks
backup "weekly/$WEEK"
fi