#!/bin/bash # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Copyright (c) 2010 FSOCA final project | http://joaosantacruz.com # This script is licensed under GNU GPL version 2.0 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Create a BASH script (run-backup.sh) to check if the file /home/$USER/tmp.back # exists on the file-system. If it does check to see if the directory /home/$USER/Backup/ # exists and if so copy all the files from /home/$USER/Documents/ to /home/$USER/Backup/ # Extension: Only backup *.odt and *.doc files if argument -d is used when running the script. # If the Backup directory doesn't exist, create it. In the backup directory create a new folder # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - clear echo "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" echo " Run Backup " echo "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" echo "" user_dir="/home/$USER/" # USER directory docs_dir="/home/$USER/Documents/" # USER documents directory bakp_dir="/home/$USER/Backup/" # USER backups directory new_folder="NewFolder" # New folder's name filename="tmp.back" # Backup filename filter="*" # Extension filter (*.odt & *.doc) if [ "$1" == "-d" ] then filter="*.odt *.doc" fi if [ -f "$user_dir$filename" ] # Check if 'backup filename' exists then if [ -d "$bakp_dir" ] # Check if 'backup directory' exists then mkdir -p $bakp_dir$new_folder cp -R $docs_dir$filter $bakp_dir echo "Backup is donne!" else mkdir $bakp_dir mkdir -p $bakp_dir$new_folder cp -R $docs_dir$filter $bakp_dir echo "Backup is donne!" fi else echo "File '$user_dir$filename' does not exists!" fi echo "" echo "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" echo "Press [enter] key to continue. . ."; read pressedKey