Add backup.sh
This commit is contained in:
20
backup.sh
Normal file
20
backup.sh
Normal file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Creates a backup and removes some of the previous backups
|
||||
# Put script in /etc/cron.daily/ and make sure it can be executed (o+x)
|
||||
|
||||
# Backups are created with the following prefix
|
||||
PREFIX="automatic-"
|
||||
# All backups with the previous prefix are deleted except the following dates
|
||||
TODAY=`date '+%Y-%m-%d'`
|
||||
YESTERDAY=`date -d "yesterday" '+%Y-%m-%d'`
|
||||
DAY_BEFORE_YESTERDAY=`date -d "2 days ago" '+%Y-%m-%d'`
|
||||
LAST_SUNDAY=`date -d "last Sunday" '+%Y-%m-%d'`
|
||||
SUNDAY_BEFORE_LAST=`date -d "last Sunday -7 days" '+%Y-%m-%d'`
|
||||
BEGINNING_OF_MONTH=`date '+%Y-%m-01'`
|
||||
BEGINNING_OF_LAST_MONTH=`date -d "last month" '+%Y-%m-01'`
|
||||
|
||||
yunohost backup create -n $PREFIX$TODAY
|
||||
cd /home/yunohost.backup/archives
|
||||
rm `ls | grep $PREFIX | grep -v "$TODAY\|$YESTERDAY\|$DAY_BEFORE_YESTERDAY\|$LAST_SUNDAY\|$SUNDAY_BEFORE_LAST\|$BEGINNING_OF_MONTH\|$BEGINNING_OF_LAST_MONTH"`
|
||||
yunohost backup list
|
Reference in New Issue
Block a user