From 4f9bb9d7fd22c2e2fdf03f048a8491e9f0e19ff7 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Tue, 16 Aug 2011 23:42:32 +0200 Subject: [PATCH] [backup] Add backup.sh Simple script to transfer a directory with rsync, with a few options. --- backup/README | 12 ++++++++++++ backup/backup.sh | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100755 backup/backup.sh diff --git a/backup/README b/backup/README index 14c7c02..f0b2f7e 100644 --- a/backup/README +++ b/backup/README @@ -1,3 +1,15 @@ +# backup.sh # + +backup.sh is a simple script that transfers a single directory (your +home directory, by default) to a remote host, using rsync. You can +specify exclude patterns in a file (~/.backup-excludes by default). +The transfer will be reattempted until it succeed. + +Edit the script to configure the protocol, host, directories, etc. + + +# backup_sites_mysql.sh # + The script backup_sites_mysql.sh is designed to save websites data files and the associated MySQL databases. diff --git a/backup/backup.sh b/backup/backup.sh new file mode 100755 index 0000000..b8e9eca --- /dev/null +++ b/backup/backup.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# +# backup.sh, Copyright © 2011 Matteo Cypriani +# +# This program is free software. It comes without any warranty, to +# the extent permitted by applicable law. You can redistribute it +# and/or modify it under the terms of the Do What The Fuck You Want +# To Public License, Version 2, as published by Sam Hocevar. See +# http://sam.zoy.org/wtfpl/COPYING for more details. +# +# Transfers a single directory to a remote host using rsync. The +# transfer is retried until it succeeds. + +# Any of the protocol supported by rsync, with the "://" (blank to use +# SSH): +PROTO=rsync:// +# Remote backup host: +HOST=vicious +# Destination of the backup on the remote host: +REMOTE_DIR=/backup + +# Local directory to backup: +LOCAL_DIR="$HOME" +# File where the excludes patterns are stored (one per line): +EXCLUDES="$HOME/.backup-excludes" +# Blank to keep the locally deleted files on the remote host (you can +# also set to --delete-after or --delete-before): +DELETE="--delete" + +false +until [ $? -eq 0 ] ; do + rsync -av ${DELETE} --exclude-from="$EXCLUDES" \ + "$LOCAL_DIR" ${PROTO}://${HOST}:"$REMOTE_DIR" +done