#!/bin/sh ## ## SCRIPT: 01_rsync_home_AcerDesktop1_to_Seagate1TB_ver1_core.sh in $HOME/Rsync ## ## PURPOSE: This script uses 'rsync' to backup data files ## (esp. home directory) --- to an external disk drive. ## ## HOW TO USE: A decktop icon can be used to run the script ## 01_rsync_home_AcerDesktop1_to_Seagate1TB_ver1_RunCoreInTerminal.sh ## which runs this script in a 'mate-terminal'. ## ## Alternatively: ## Open a terminal at home directory, 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.) ## ## ## METHOD OF IMPLEMENTATION: ## ## 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 --- ## that is, it removes files from the 'dest' directory that are no longer ## in the 'source' directory. ## ## The '--archive' option causes all file permissions and timestamps to be copied to. ## ## The 'rsync' man page says: ## ## -a, --archive archive mode; equals -rlptgoD (no -H,-A,-X) ## ## *********************************************************************************** ## *** 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 -v --modify-window=1 \ ## /home/ /media/blaze/Seagate1/home/ ## ## Could try -vv instead of -v. Could try -q instead of -v. ## ## ## Created: 2019oct25 from rsync scripts on old 'home-built' computer ## Changed: 2019nov02 Removed '--dry-run' parm. ## Changed: 2020aug24 Removed '--progress' parm. FROMdir="/home/" TOdir="/media/blaze/Seagate1TB/home/" ## NOTE: Ending slashes. 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 ## USE ONE OF THE FOLLOWING for the first line of the cmd. ## ## rsync --dry-run --progress --stats \ ## OR ## rsync --progress --stats \ ## OR ## rsync --stats \ rsync --stats \ --archive --delete -v --modify-window=1 \ "$FROMdir" "$TOdir" read PRESS_ANY_KEY_toContinue set -