diff options
author | lookshe <github@lookshe.org> | 2014-09-20 19:35:48 +0200 |
---|---|---|
committer | lookshe <github@lookshe.org> | 2014-09-20 19:35:48 +0200 |
commit | 0d5cfba20946f9d02a2677c0362a69bc781e68c2 (patch) | |
tree | d2ac2d2f77332c8d05b8ee54593c6aa7511b500f | |
parent | 105fe23bb3a47237135fedb67a638a5e5cffa148 (diff) |
Create backup.sh
-rw-r--r-- | backup.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/backup.sh b/backup.sh new file mode 100644 index 0000000..c974453 --- /dev/null +++ b/backup.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +#device=`udevadm info --query=path --name=/dev/backup --attribute-walk | egrep "looking at parent device" | head -1 | sed -e "s/.*looking at parent device '\(\/devices\/.*\)\/.*\/host.*/\1/g"` + +#echo on > /sys$device/power/level + +mount -t ext3 /dev/backup /media/backup + +if [ -e /tmp/deletebackup ] +then + + rsync -a --delete /media/usb-3 /media/backup + rsync -a --delete /home/lookshe /media/backup + +else + + rsync -a /media/usb-3 /media/backup + rsync -a /home/lookshe /media/backup + +fi + +rsync -a /etc /media/backup + +if [ ! -e /tmp/keepbackup ] +then + + umount /media/backup + + sync + + sdparm --command=sync /dev/backup > /dev/null + sdparm --command=stop /dev/backup > /dev/null + +# deviceid=`udevadm info --query=path --name=/dev/backup --attribute-walk | egrep "looking at parent device" | head -1 | sed -e "s/.*looking at parent device '\/devices\/.*\/\(.*\)\/.*\/host.*/\1/g"` + +# echo -n "$deviceid" > /sys/bus/usb/drivers/usb/unbind + +# echo suspend > /sys$device/power/level + +fi |