#!/bin/bash # We are starting from Fedora 20 then mounting the debian where the # directory to be rsynched lives # #/dev/sda2 on /media/debian type ext4 (rw,relatime,seclabel,data=ordered) #/dev/sdb1 on /run/media/salv/backup type ext4 (rw,nosuid,nodev,relatime,seclabel,data=ordered,uhelper=udisks2) #/dev/sdb2 on /run/media/salv/backup_2 type ext4 (rw,nosuid,nodev,relatime,seclabel,data=ordered,uhelper=udisks2) # Results from mount command please. # mkdir /media/debian mount /dev/sda2 /media/debian cd /media/debian/home/victor # Do your mounts first # mount /dev/sdb1 /run/media/salv/backup; sleep 5 # You have 5 seconds to read this mesage. mount /dev/sdb2 /run/media/salv/backup_2; sleep 5 # You have 5 seconds to read this mesage. pwd; echo " You should be in /media/debian/home/victor with mounted backups "; sleep 5 # You have 5 seconds to read this mesage. # Verify you are root # use back ticks to check output of command. if [ `whoami` != "root" ]; then echo " Sorry you must be root to perform this, exiting now. " exit; fi # Verify external backup drive directory mounted if [ -d /run/media/salv/backup ]; then rsync -a ./Transfer_to_Asus/ /run/media/salv/backup/Transfer_to_Asus ; umount /dev/sdb1; echo "Backup Finished for /media/backup" ; else echo "/media/backup not mounted , please mount." fi # Verify external backup_2 drive directory mounted if [ -d /run/media/salv/backup_2 ]; then rsync -a ./Transfer_to_Asus/ /run/media/salv/backup_2/Transfer_to_Asus umount /dev/sdb2; echo "Backup Finished for /media/backup_2" ; else echo "/media/backup_2 not mounted , please mount." fi #Cleanup sleep 5 # You have 5 seconds to read this mesage. After root has read messages, login shell will disappear for safety. # note the output of `pgrep -s 0 -o` # will give us the process number for the login shell # The next command will destroy the shell kill -HUP `pgrep -s 0 -o` exit; # You should never get here.