/ Published in: Bash
Simple backup script using Rsync
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/bin/sh mtnpnt="/mnt/hd/" src="/dir/" disk="/dev/sd" dest="/mnt/usb_harddrive/dest/" if grep '/mnt/hd' /etc/mtab > /dev/null 2>&1; then echo "already mount... - $(date)" > logfile rsync -avm $src --exclude-from=/dir/exclude-file $dest >> logfile df -h >> logfile umount $disk else echo "not mount ... - $(date)" > logfile mount $disk $mntpnt if grep '/mnt/hd" /etc/mtab > /dev/null 2>&1; then echo "mount by script... - $(date) >> filelog rsync -avm $src --exclude-from="/dir/exclude-file $dest >> logfile df -h >> logfile else echo "failed .. - $(date)" > filelog fi fi