#!/bin/bash # Do your mounts first # For some reason this Debian makes external drive sdc instead of sdb # Go figure ! # Check your system first with mount command please. # mount /dev/sdc1 /media/backup; sleep 5 # You have 5 seconds to read this mesage. mount /dev/sdc2 /media/backup_2; sleep 5 # You have 5 seconds to read this mesage. pwd; echo " You should be in /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 /media/backup ]; then rsync -a ./Transfer_to_Asus/ /media/backup/Transfer_to_Asus ; umount /dev/sdc1; echo "Backup Finished for /media/backup" ; else echo "/media/backup not mounted , please mount." fi # Verify external backup_2 drive directory mounted if [ -d /media/backup_2 ]; then rsync -a ./Transfer_to_Asus/ /media/backup_2/Transfer_to_Asus umount /dev/sdc2; 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.