#!/bin/sh
##
# Description: SSH/Fuse mount, backup and umount script.
# Execute via cron for schedule backups over
# secure shell.
#
# Author: Jordan DeLozier
# Date: 1-19-2009
# Usage: ./BackupScript.sh
#
# Must run as root
# Must use SSH Key Authentication for automatic updates
##
# For some reason the kernel module doesn't always
# load on boot. Load it now
/sbin/modprobe fuse
# Mount the remote SSH machine, if there
# is an error exit. This prevents the files from
# being copied to the local machine and using
# local hard disk space
#
# Replace <username>,<server>,/path/to/files/ and /mnt/<dir> with
# proper values.
##
if (!(/usr/local/bin/sshfs <username>@<server>:/path/to/files/ /mnt/<dir>)); then
echo "Mount Failed"
exit 1
fi
# Copy the Files
# Using -Ru recursively copies and only copies
# files that are different from the target.
#
# Replace /source/files and /mnt/<dir of mount>
##
cp -Ru /source/files/ /mnt/<dir of mount>
# Unmount
#
# Replace /mnt/<dir of mount>
##
umount /mnt/<dir of mount>
Use it, change it, distribute it. Please consider linking back to the source when you do if possible.
Edited by Jordan, 17 June 2009 - 12:04 PM.


Sign In
Create Account

Guest_Jordan_*
Back to top










