Created
May 2, 2013 21:06
-
-
Save yourdesigncoza/5505466 to your computer and use it in GitHub Desktop.
RSYNC is a software application for Unix systems which synchronizes files and directories from one location to another
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RSYNC is a software application for Unix systems which synchronizes files and directories from one location to another ::: | |
# IMPORTANT : add your own data or parameters, I make use of double segments [[ your variable ]]. eg. ssh root@[[ 96.172.44.11 ]] should be replaced with ssh [email protected] where "888.88.88.88" is your value, variable etc. I have a habit of using ":::" to indicate line ending and end of paragraph, crazy I know but be warned its just how I write ::: All notes are for my own use & should you use any it's at your own risk, it's NOT a Tutorial ::: | |
# Backing up files can be simple like my example below, or a bit more complicated backing up with RSYNC to another server etc. I did not need anything "complicated" but if you require exteral sync, below are several links to get you going ::: | |
# resources | |
# https://help.ubuntu.com/community/CronHowto | |
# https://help.ubuntu.com/community/rsync | |
# http://ubuntuforums.org/showthread.php?t=1141113 | |
# https://help.ubuntu.com/12.04/serverguide/backup-shellscripts.html | |
# http://www.cyberciti.biz/faq/linux-unix-formatting-dates-for-display/ | |
# http://www.jveweb.net/en/archives/2010/11/synchronizing-folders-with-rsync.html | |
# http://www.jveweb.net/en/archives/2011/02/using-rsync-and-cron-to-automate-incremental-backups.html | |
# http://rsync.samba.org/examples.html | |
# http://nwlinux.com/how-to-configure-and-ubuntu-rsync-server/ | |
######################## | |
# Backup WP Folders | |
######################## | |
# Create a directory preferably outside wwww : eg. [[ user ]]/var/[[ BU-folder ]] | |
sudo mkdir /var/[[ BU-folder ]] | |
# Lets create a shell scrip to BU some folders, in a Typical WP install this would be the "wp-content" folder | |
# You will notice I added a "day_stamp, this will add the day of the week eg Thursday will be "4", This way I alwas have a 7 day backup ::: | |
## START SHELL SCRIPT | |
#!/bin/sh | |
#################################### | |
# | |
# Backup Typical Wordpress Folders. | |
# | |
#################################### | |
# Format day eg. 1 | |
day_stamp=$(date +%u) | |
# Use RSYNC to backup | |
rsync -az /var/www/wp-content /var/[[ yourdir ]]/wp-content_$day_stamp | |
## END SHELL SCRIPT | |
# Lets run a Cron | |
# Example Schedule | |
# Backup Wordpress Site Files Daily @ 01:00 AM | |
# m h dom mon dow command | |
00 01 * * * bash /var/www/[[ yourdir ]]/bu-wp-content.sh | |
######################## | |
# Notes | |
######################## | |
# If you get an error like this : line 8: $'\r': command not found , you have CRLF line endings (that's \r\n in C and related languages). | |
# The simplest is to install dos2unix | |
sudo apt-get install dos2unix | |
# Then run | |
sudo dos2unix /var/www/[[ yourdir ]]/bu-wp-content.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment