#!/bin/sh ## ## SCRIPT: 00_rsync_maxtor160GB_to_Seagate1TB.sh in $HOME/Rsync ## ## PURPOSE: This script uses 'rsync' to backup data files ## (esp. home directory) --- to an external disk drive. ## ## HOW TO USE: Open a terminal, cd Rsync, and run this script --- ## after the external disk drives are attached and running (powered up). ## ## (It is good to check the current size of the home directory to see if ## if fits on the external drive.) ## ## Reference: Linux Format Magazine #130, Apr 2010, p.105, Answers section ## ## 'rsync' only copies files that are different. With large files that ## have changed, it only copies the parts that have been altered. ## Its main parameters are a 'from' directory and a 'to' directory. ## Example: ## rsync --archive --delete /path/to/source/ /path/to/dest/ ## ## The '--delete' option removes files not present on the first directory. ## The '--archive' option causes all file permissions and timestamps to be copied to. ## ## The trailing slashes on the directory names are important because they indicate ## that you want to sync the contents of the folders. If you omit them, you could ## end up copying one directory into another. ## ## Since we may be using an MS Windows FAT file system on the 'to' drive, ## we use '--modify-window=1', as explained here: ## --modify-window ## When comparing two timestamps, rsync treats the timestamps as ## being equal if they differ by no more than the modify-window ## value. This is normally 0 (for an exact match), but you may ## find it useful to set this to a larger value in some situations. ## In particular, when transferring to or from an MS Windows FAT ## filesystem (which represents times with a 2-second resolution), ## --modify-window=1 is useful (allowing times to differ by up to 1 ## second). ## ## Examples: ## rsync --archive --delete /path/to/source/ /path/to/dest/ ## rsync --archive --delete -vv --modify-window=1 /home/blaze/ /media/Maxtor160GB/home/blaze/ ## Could try -vv instead of -v. Could try -q instead of -v. ## ## ## Could run rsync cmd in a terminal with: ## ## gnome-terminal -e "$HOME/Rsync/start_sh_after_exe.sh \ ## rsync ..." ## ## Created: 2019oct25 from old 'home-built' rsync script ## Changed: FROMdir="/media/blaze/Maxtor160GB/home/blaze/" TOdir="/media/blaze/Seagate1TB/BKUP_home_home-built_2019oct23_PREfinalRsync/blaze/" if test ! -d "$FROMdir" then echo " Directory $FROMdir does not exist. Exiting." exit fi if test ! -d "$TOdir" then echo " Directory $TOdir does not exist. Exiting." exit fi ## You can add '--dry-run' (or '-n') to ## perform a trial run that doesn't make any ## changes (and produces mostly the same output as a real run). ## ## dry-run is most commonly used in combination with the -v, --verbose ## and/or -i, --itemize-changes options to see what an rsync ## com## mand is going to do before one actually runs it. ## You can try '--progress' ## It tells rsync to print information showing the ## progress of the transfer. This gives a bored user something to ## watch. With a modern rsync this is the same as specifying ## --info=flist2,name,progress, but any user-supplied settings for ## those info flags takes precedence (e.g. "--info=flist0 ## --progress"). ## ## While rsync is transferring a regular file, it updates a ## progress line that looks like this: ## ## 782448 63% 110.64kB/s 0:00:04 ## set -x # rsync --dry-run --progress --stats \ rsync --dry-run --progress --stats \ --archive --delete -v --modify-window=1 \ "$FROMdir" "$TOdir" set -