Scripts for a Yunohost box
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
880B

  1. #!/bin/bash
  2. # Creates a backup and removes some of the previous backups
  3. # Put script in /etc/cron.daily/ and make sure it can be executed (o+x)
  4. # Backups are created with the following prefix
  5. PREFIX="automatic-"
  6. # All backups with the previous prefix are deleted except the following dates
  7. TODAY=`date '+%Y-%m-%d'`
  8. YESTERDAY=`date -d "yesterday" '+%Y-%m-%d'`
  9. DAY_BEFORE_YESTERDAY=`date -d "2 days ago" '+%Y-%m-%d'`
  10. LAST_SUNDAY=`date -d "last Sunday" '+%Y-%m-%d'`
  11. SUNDAY_BEFORE_LAST=`date -d "last Sunday -7 days" '+%Y-%m-%d'`
  12. BEGINNING_OF_MONTH=`date '+%Y-%m-01'`
  13. BEGINNING_OF_LAST_MONTH=`date -d "last month" '+%Y-%m-01'`
  14. yunohost backup create -n $PREFIX$TODAY
  15. cd /home/yunohost.backup/archives
  16. rm `ls | grep $PREFIX | grep -v "$TODAY\|$YESTERDAY\|$DAY_BEFORE_YESTERDAY\|$LAST_SUNDAY\|$SUNDAY_BEFORE_LAST\|$BEGINNING_OF_MONTH\|$BEGINNING_OF_LAST_MONTH"`
  17. yunohost backup list