aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2010-06-20 21:44:58 +0300
committerFilipp Lepalaan <filipp@mac.com>2010-06-20 21:44:58 +0300
commit85406dae0c220759da4b816fa9380c25d72b73ba (patch)
tree0390e68282697fa7873e3bf44f9abff667359079
downloadoffsync-85406dae0c220759da4b816fa9380c25d72b73ba.tar.gz
offsync-85406dae0c220759da4b816fa9380c25d72b73ba.tar.bz2
offsync-85406dae0c220759da4b816fa9380c25d72b73ba.zip
First commit
-rw-r--r--.gitignore3
-rwxr-xr-xREADME81
-rwxr-xr-xconfig.default4
-rw-r--r--offsync.include.default0
-rwxr-xr-xstart.sh25
-rwxr-xr-xstop.sh12
6 files changed, 125 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..473014b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+config
+offsync.include
+
diff --git a/README b/README
new file mode 100755
index 0000000..565886c
--- /dev/null
+++ b/README
@@ -0,0 +1,81 @@
+# README
+# @author Filipp Lepalaan <filipp@mcare.fi>
+# @date 06.06.2010
+
+# Introduction
+This is an offsite backup solution based on rsync and launchd. It's pretty easy to use and
+set up.
+
+# Files
+- start_offsite.sh the main script that does the actual backup and notification
+- stop_offsite.sh the script to stop the backup in case it exceeds a time limit
+- offsite_include.sh paths to files and directories to back up
+
+# Installation
+- Make sure both the client and the server are running the same version of rsync.
+The Mac ToolKit (http://github.com/filipp/mtk) has a script to build the latest
+rsync with all the Mac-specific patches
+- Install rsync to /usr/local/bin/
+- Make sure your firewall permits traffic on 873 TCP/UDP
+- Create rsyncd.conf on the server and configure to your liking
+- Start rsync in daemon mode on the server
+- Edit start_offsite.sh to match your environment
+- Add stuff to backup into offsite_include.txt
+- Create two launchd jobs, one to run start_offsite.sh and the other to stop_offsite.sh, you can
+name them whatever you like
+- Load the new launchd plists
+
+# Operation
+
+start_offsite.sh spawns off rsync with all the apropriate switches (including --delete!)
+You can monitor the progress of the backup by tailing offsite.log
+The system will send some stats to the specified email address once the process is complete
+
+# launchd plists
+You need two of these, one to start, something like:
+
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>Label</key>
+ <string>offsync.start</string>
+ <key>ProgramArguments</key>
+ <array>
+ <string>/Library/offsync/start.sh</string>
+ </array>
+ <key>StartCalendarInterval</key>
+ <dict>
+ <key>Hour</key>
+ <integer>23</integer>
+ <key>Minute</key>
+ <integer>0</integer>
+ </dict>
+ <key>AbandonProcessGroup</key>
+ <true/>
+</dict>
+</plist>
+
+and the second one to stop:
+
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>Label</key>
+ <string>offsync.stop</string>
+ <key>ProgramArguments</key>
+ <array>
+ <string>/Library/offsync/start.sh</string>
+ </array>
+ <key>StartCalendarInterval</key>
+ <dict>
+ <key>Hour</key>
+ <integer>7</integer>
+ <key>Minute</key>
+ <integer>0</integer>
+ </dict>
+ <key>AbandonProcessGroup</key>
+ <true/>
+</dict>
+</plist>
diff --git a/config.default b/config.default
new file mode 100755
index 0000000..ba5d072
--- /dev/null
+++ b/config.default
@@ -0,0 +1,4 @@
+LOGNAME=""
+MAILTO=""
+RSYNC_PASSWORD=""
+RSYNC_TARGET=""
diff --git a/offsync.include.default b/offsync.include.default
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/offsync.include.default
diff --git a/start.sh b/start.sh
new file mode 100755
index 0000000..351474b
--- /dev/null
+++ b/start.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+# offsync/start.sh
+# run the offsite backup
+
+MYDIR=$(dirname $0)
+source "${MYDIR}/config"
+
+if -z "${RSYNC_TARGET}"; then
+ echo "Check your configuration!" 2>&1
+ exit 1
+fi
+
+date >> "${LOGFILE}"
+/usr/local/bin/rsync -auvhNHXxrz\
+ --stats --protect-args --fileflags --force-change --delete\
+ --files-from="$MYDIR/offsync.include" --no-relative\
+ / "${RSYNC_TARGET}" >> "$LOGFILE" 2>&1 &
+
+echo $! > "$PIDFILE"
+
+# wait for rsync to finish
+wait $(cat "$PIDFILE")
+rm "$PIDFILE"
+
+tail "$LOGFILE" | mail -E -s "Offsite backup of $(hostname) completed" $MAILTO
diff --git a/stop.sh b/stop.sh
new file mode 100755
index 0000000..56ebb29
--- /dev/null
+++ b/stop.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+# offsync/stop.sh
+# interrupts the offsite job in the morning
+
+MYDIR=$(dirname $0)
+source "${MYDIR}/config"
+
+if -z "${PIDFILE}"; then
+ echo "Check your configuration!" 2>&1
+fi
+
+kill $(cat "$PIDFILE") && rm "${PIDFILE}"