Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. BACKUPDIR=/var/backups/files
  4. ROTATE=1
  5.  
  6. mkdir -p $BACKUPDIR
  7.  
  8. CURRENT="$BACKUPDIR/`date +%Y-%m-%d`-files.tar.gz"
  9.  
  10. cd /var/ && tar czf $CURRENT www
  11.  
  12. find $BACKUPDIR -type f -mtime $ROTATE -exec rm {} ;
  13.  
  14. chmod 0600 $BACKUPDIR/*
  15.  
  16. find $BACKUPDIR -type f -mtime $ROTATE -exec rm {} ;
  17.  
  18. #!/bin/sh -e
  19.  
  20. BACKUPDIR=/var/backups/files
  21.  
  22. # I suggest a little more than 1 day (i.e. about 1 week of backups is
  23. # probably safer.)
  24. ROTATE=7
  25.  
  26. mkdir -p $BACKUPDIR
  27.  
  28. CURRENT="$BACKUPDIR/`date +%Y-%m-%d`-files.tar.gz"
  29.  
  30. # Create protected file, then backup data in it
  31. touch $CURRENT
  32. chmod 600 $CURRENT
  33. cd /var/ && tar czf $CURRENT www
  34.  
  35. # Here we have the attempt at deleting, notice the "+"
  36. find $BACKUPDIR -type f -name '*-files.tar.gz' -mtime +$ROTATE -delete
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement