pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

pastebin private pastebin - collaborative debugging tool What's a private pastebin?

Posted by frymaster on Sat 10th Dec 19:17
download | new post

  1. #!/bin/bash
  2.  
  3. #include-file is a list of paths to back up (e.g. /var/www)
  4. #exclude-file is a list of paths NOT to back up (e.g. /var/www/minecraft/overhead/maps)
  5. #"server" is if you want to back up stuff on a different machine (you'd put e.g. "user@machine:" in there)
  6.  
  7. echo `date +%y-%m-%d--%H%M` "start backup script"
  8. #dest is year-month-day--hourminute
  9. #ie 2008-09-01--1237
  10.  
  11. if [ $UID -ne 0 ]; then
  12.         sl
  13.         echo "This must be run as root"
  14.         exit
  15. fi
  16.  
  17. timestamp=`date +%y-%m-%d--%H%M`
  18. backup_location=/backup
  19. server=
  20. include_file=$backup_location/include
  21. exclude_file=$backup_location/exclude
  22. link_dest=`ls -dt $backup_location/??-??-??--????*/ | head -n 1`
  23.  
  24. #This is a file I have which conditionally removes old backups (keeping first-of-week in preference to dailies, and first-of-month in preference to either)
  25. #echo `date +%y-%m-%d--%H%M` "Check free space"
  26. #$backup_location/check-backup-space.py
  27.  
  28. #If you want mysql backed up, uncomment this:
  29. #echo Backup up MYSQL database
  30. #nice ionice -n7 mysqldump --all-databases -u root -h localhost -pLOLNOTHISISNTMYPASSWORD > /var/mysql-backups/sql$timestamp.sql && nice ionice -n7 gzip -9 /var/mysql-backups/sql$timestamp.sql
  31. #cp /var/mysql-backups/sql$timestamp.sql.gz /var/mysql-backups/last_backup.sql.gz
  32.  
  33. echo `date +%y-%m-%d--%H%M` "Copying over files"
  34.  
  35. for i in $(  sed 's/ *#.*//' $include_file ); do
  36.  
  37.  
  38.      echo $i
  39.      nice rsync -maz -l --relative --link-dest=$link_dest --exclude-from="$exclude_file" $server$i $backup_location/$timestamp
  40.  
  41. done
  42.  
  43. rm $backup_location/last_backup
  44. ln -s $backup_location/$timestamp $backup_location/last_backup
  45.  
  46. echo `date +%y-%m-%d--%H%M` "backup complete! \o/"

Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Use syntax highlighting

To highlight particular lines, prefix each line with @@


Remember my settings