Skip to content

Commit

Permalink
Enable --files-from flag of rsync
Browse files Browse the repository at this point in the history
However, it's not backward compatible
  • Loading branch information
deeperlearner committed Jul 17, 2021
1 parent a4babee commit 2349d61
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ You can set some configuration variables to customize the script:
* `nameBakN`: Name of incremental backup directories. An index will be added at the end to show how old they are.
* `logName`: Name given to log file generated at backup.
* `exclusionFileName`: Name given to the text file that contains exclusion patterns. You must create it inside directory defined by `ownFolderName`.
* `source_fileFileName`: Name given to the text file that contains list of source-file names. You must create it inside directory defined by `ownFolderName`.
* `ownFolderName`: Name given to folder inside user's home to hold configuration files and logs while backup is in progress.
* `logFolderName`: Directory inside `dst` where the log files are stored.
* `dateCmd`: Command to run for GNU `date`
Expand Down Expand Up @@ -142,6 +143,7 @@ Log files per backup operation will be stored at `<dst>/log`.
* `--chmod`: affect file and/or directory permissions.
* `--exclude`: exclude files matching pattern.
* `--exclude-from`: same as `--exclude`, but getting patterns from specified file.
* `--files-from`: read list of source-file names from `source_fileFileName`

* Used only for remote backup:
* `--no-W`: ensures that rsync's delta-transfer algorithm is used, so it never transfers whole files if they are present at target. Omit only when you have a high bandwidth to target, backup may be faster.
Expand Down
5 changes: 4 additions & 1 deletion rsync-incremental-backup-local
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ rotationLockFileName="${rotationLockFileName:-.rsync-rotation-lock}"
pathBakN="${pathBakN:-backup}"
nameBakN="${nameBakN:-backup}"
exclusionFileName="${exclusionFileName:-exclude.txt}"
source_fileFileName="${source_fileFileName:-source_file.txt}"
dateCmd="${dateCmd:-date}"
logName="${logName:-rsync-incremental-backup_$(${dateCmd} +%Y-%m-%d)_$(${dateCmd} +%H-%M-%S).log}"
ownFolderName="${ownFolderName:-.rsync-incremental-backup}"
Expand All @@ -19,6 +20,7 @@ logFolderName="${logFolderName:-log}"
ownFolderPath="${HOME}/${ownFolderName}"
tempLogPath="${ownFolderPath}/local_${dst//[\/]/\\}"
exclusionFilePath="${ownFolderPath}/${exclusionFileName}"
source_fileFilePath="${ownFolderPath}/${source_fileFileName}"
bak0="${dst}/${pathBak0}"
rotationLockFilePath="${dst}/${rotationLockFileName}"
logPath="${dst}/${pathBakN}/${logFolderName}"
Expand All @@ -28,6 +30,7 @@ logFile="${tempLogPath}/${logName}"
mkdir -p "${tempLogPath}"
touch "${logFile}"
touch "${exclusionFilePath}"
touch "${source_fileFilePath}"

writeToLog() {
echo -e "${1}" | tee -a "${logFile}"
Expand Down Expand Up @@ -104,7 +107,7 @@ writeToLog "[$(${dateCmd} -Is)] Backup begins\\n"
# Do the backup
if rsync -achv --progress --timeout="${timeout}" --delete -W --link-dest="${bak1}/" \
--log-file="${logFile}" --exclude="${ownFolderPath}" --chmod=+r \
--exclude-from="${exclusionFilePath}" "${src}/" "${bak0}/"
--exclude-from="${exclusionFilePath}" --files-from="${source_fileFilePath}" "${src}/" "${bak0}/"
then
writeToLog "\\n[$(${dateCmd} -Is)] Backup completed successfully\\n"

Expand Down
5 changes: 4 additions & 1 deletion rsync-incremental-backup-remote
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ rotationLockFileName="${rotationLockFileName:-.rsync-rotation-lock}"
pathBakN="${pathBakN:-backup}"
nameBakN="${nameBakN:-backup}"
exclusionFileName="${exclusionFileName:-exclude.txt}"
source_fileFileName="${source_fileFileName:-source_file.txt}"
dateCmd="${dateCmd:-date}"
logName="${logName:-rsync-incremental-backup_$(${dateCmd} +%Y-%m-%d)_$(${dateCmd} +%H-%M-%S).log}"
ownFolderName="${ownFolderName:-.rsync-incremental-backup}"
Expand All @@ -22,6 +23,7 @@ interactiveMode="${interactiveMode:-no}"
ownFolderPath="${HOME}/${ownFolderName}"
tempLogPath="${ownFolderPath}/${remote}_${dst//[\/]/\\}"
exclusionFilePath="${ownFolderPath}/${exclusionFileName}"
source_fileFilePath="${ownFolderPath}/${source_fileFileName}"
remoteDst="${remote}:${dst}"
bak0="${dst}/${pathBak0}"
remoteBak0="${remoteDst}/${pathBak0}"
Expand All @@ -35,6 +37,7 @@ logFile="${tempLogPath}/${logName}"
mkdir -p "${tempLogPath}"
touch "${logFile}"
touch "${exclusionFilePath}"
touch "${source_fileFilePath}"

writeToLog() {
echo -e "${1}" | tee -a "${logFile}"
Expand Down Expand Up @@ -131,7 +134,7 @@ writeToLog "[$(${dateCmd} -Is)] Backup begins\\n"
# Do the backup
if rsync "${rsyncShellParams[@]}" -achvz --progress --timeout="${timeout}" --delete --no-W \
--partial-dir="${partialFolderName}" --link-dest="${bak1}/" --log-file="${logFile}" --exclude="${ownFolderPath}" \
--chmod=+r --exclude-from="${exclusionFilePath}" "${src}/" "${remoteBak0}/"
--chmod=+r --exclude-from="${exclusionFilePath}" --files-from="${source_fileFilePath}" "${src}/" "${remoteBak0}/"
then
writeToLog "\\n[$(${dateCmd} -Is)] Backup completed successfully\\n"

Expand Down

0 comments on commit 2349d61

Please sign in to comment.