From 27a98fb54beb47bfd56af363de1b27581b972b6e Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sun, 12 Jan 2014 03:09:12 +0800 Subject: [PATCH 01/11] Added TODO to README.md --- README.md | 2 ++ rsync_tmbackup.sh | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ba5ee89..fe76560 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,8 @@ An optional exclude file can be provided as a third parameter. It should be comp # TODO +* Check source and destination file-system. If one of them is FAT, use the --modify-window rsync parameter (see `man rsync`) with a value of 1 or 2. + * Minor changes (see TODO comments in the source). * Backup to remote drive? diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh index a467755..7a1f355 100755 --- a/rsync_tmbackup.sh +++ b/rsync_tmbackup.sh @@ -29,6 +29,7 @@ fn_parse_date() { # Converts YYYY-MM-DD-HHMMSS to YYYY-MM-DD HH:MM:SS and then to Unix Epoch. case "$OSTYPE" in linux*) date -d "${1:0:10} ${1:11:2}:${1:13:2}:${1:15:2}" +%s ;; + cygwin*) date -d "${1:0:10} ${1:11:2}:${1:13:2}:${1:15:2}" +%s ;; darwin*) date -j -f "%Y-%m-%d-%H%M%S" "$1" "+%s" ;; esac } @@ -46,7 +47,7 @@ fn_expire_backup() { fi fn_log_info "Expiring $1" - rm -rf -- "$1" + # rm -rf -- "$1" } # ----------------------------------------------------------------------------- @@ -239,6 +240,7 @@ while : ; do # ----------------------------------------------------------------------------- # Check whether rsync reported any errors # ----------------------------------------------------------------------------- + if [ -n "$(grep "rsync:" "$LOG_FILE")" ]; then fn_log_warn "Rsync reported a warning, please check '$LOG_FILE' for more details." fi From 12930a24ebcac25988678c17177cf05323677f26 Mon Sep 17 00:00:00 2001 From: Erik Jansson Date: Tue, 14 Jan 2014 13:55:43 +0100 Subject: [PATCH 02/11] Fix expiring old backups This got (accidentally?) turned off in a previous commit. --- rsync_tmbackup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh index 7a1f355..e5192bd 100755 --- a/rsync_tmbackup.sh +++ b/rsync_tmbackup.sh @@ -47,7 +47,7 @@ fn_expire_backup() { fi fn_log_info "Expiring $1" - # rm -rf -- "$1" + rm -rf -- "$1" } # ----------------------------------------------------------------------------- From 2c9805b450cc4d0b67f22de55474428816a44d84 Mon Sep 17 00:00:00 2001 From: Utkarsh Upadhyay Date: Sun, 26 Jan 2014 21:20:49 +0100 Subject: [PATCH 03/11] Fix minor typos in the README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fe76560..973cec4 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Time Machine style backup with rsync. Should work on Linux (tested), Mac OS X (t ## Exclude file -An optional exclude file can be provided as a third parameter. It should be compabible with the `--exclude-from` parameter of rsync. See [this tutorial] (https://sites.google.com/site/rsync2u/home/rsync-tutorial/the-exclude-from-option) for more information. +An optional exclude file can be provided as a third parameter. It should be compatible with the `--exclude-from` parameter of rsync. See [this tutorial] (https://sites.google.com/site/rsync2u/home/rsync-tutorial/the-exclude-from-option) for more information. # Features @@ -30,7 +30,7 @@ An optional exclude file can be provided as a third parameter. It should be comp * Files that haven't changed from one backup to the next are hard-linked to the previous backup so take very little extra space. -* Safety check - the backup will only happen if the destination has explicitely been marked as a backup destination. +* Safety check - the backup will only happen if the destination has explicitly been marked as a backup destination. * Resume feature - if a backup has failed or was interrupted, the tool will resume from there on the next backup. From 64f7005ab7c4208bda27dae3bbceac56bec6dbc7 Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 3 Feb 2014 02:05:10 +0800 Subject: [PATCH 04/11] Update README.md Update compatibility. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 973cec4..218c8e7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Rsync time backup -Time Machine style backup with rsync. Should work on Linux (tested), Mac OS X (tested) and Windows with Cygwin (not tested yet but feedback would be welcome). +Time Machine style backup with rsync. Should work on Linux, OS X and Windows with Cygwin. # Installation From 7265d26b0bca59a1b9e82e334ec5affae70012b2 Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 3 Feb 2014 02:19:25 +0800 Subject: [PATCH 05/11] Update README.md Clarify advantages/disadvantages --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 218c8e7..655f385 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Rsync time backup -Time Machine style backup with rsync. Should work on Linux, OS X and Windows with Cygwin. +Time Machine style backup with rsync. Should work on Linux, OS X and Windows with Cygwin. The main advantage over Time Machine is the flexibility as it can backup from/to any filesystem and works on any platform. You can also backup, for example, to a Truecrypt drive without any problem. + +On OS X, it has a few disadvantages compared to Time Machine - in particular it doesn't auto-start when the backup drive is plugged (though it can be achieved using a launch agent), and no specific GUI is provided to restore files. Instead files can be restored by using any file explorer, including Finder, or the command line. # Installation From 1384fdfd1cb0f01e804d57b69ac1e28247511677 Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 3 Feb 2014 02:20:46 +0800 Subject: [PATCH 06/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 655f385..128cda6 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Time Machine style backup with rsync. Should work on Linux, OS X and Windows with Cygwin. The main advantage over Time Machine is the flexibility as it can backup from/to any filesystem and works on any platform. You can also backup, for example, to a Truecrypt drive without any problem. -On OS X, it has a few disadvantages compared to Time Machine - in particular it doesn't auto-start when the backup drive is plugged (though it can be achieved using a launch agent), and no specific GUI is provided to restore files. Instead files can be restored by using any file explorer, including Finder, or the command line. +On OS X, it has a few disadvantages compared to Time Machine - in particular it doesn't auto-start when the backup drive is plugged (though it can be achieved using a launch agent), it requires some knowledge of the command line, and no specific GUI is provided to restore files. Instead files can be restored by using any file explorer, including Finder, or the command line. # Installation From 1a3dc0b144183926435cc6bfd3c2942e6cc30361 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Mon, 28 Apr 2014 22:18:32 -0300 Subject: [PATCH 07/11] More complete command --- rsync_tmbackup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh index e5192bd..b827075 100755 --- a/rsync_tmbackup.sh +++ b/rsync_tmbackup.sh @@ -78,7 +78,7 @@ if [ -z "$(fn_find_backup_marker "$DEST_FOLDER")" ]; then fn_log_info "Safety check failed - the destination does not appear to be a backup folder or drive (marker file not found)." fn_log_info "If it is indeed a backup folder, you may add the marker file by running the following command:" fn_log_info "" - fn_log_info "touch \"$(fn_backup_marker_path "$DEST_FOLDER")\"" + fn_log_info "mkdir -p -- \"$DEST_FOLDER\" ; touch \"$(fn_backup_marker_path "$DEST_FOLDER")\"" fn_log_info "" exit 1 fi From 21c24be547834b9182734150b629b6f4c43a0806 Mon Sep 17 00:00:00 2001 From: lau Date: Fri, 19 Sep 2014 11:02:32 +0200 Subject: [PATCH 08/11] Update README.md Added complete license --- README.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 128cda6..d03df91 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,26 @@ An optional exclude file can be provided as a third parameter. It should be comp # LICENSE -[MIT](http://opensource.org/licenses/MIT) +The MIT License (MIT) + +Copyright (c) 2013-2014 Laurent Cozic + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/laurent22/rsync-time-backup/trend.png)](https://bitdeli.com/free "Bitdeli Badge") From 5740b9a43ee8fa44627c13852afd16297d4878eb Mon Sep 17 00:00:00 2001 From: eaut Date: Fri, 13 Feb 2015 22:51:59 +0100 Subject: [PATCH 09/11] prevent execution of concurrent backup tasks --- rsync_tmbackup.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh index b827075..553dcd6 100755 --- a/rsync_tmbackup.sh +++ b/rsync_tmbackup.sh @@ -113,6 +113,10 @@ fi # ----------------------------------------------------------------------------- if [ -f "$INPROGRESS_FILE" ]; then + if pgrep -F "$INPROGRESS_FILE" > /dev/null 2>&1 ; then + fn_log_error "Previous backup task is still active - aborting." + exit 1 + fi if [ -n "$PREVIOUS_DEST" ]; then # - Last backup is moved to current backup folder so that it can be resumed. # - 2nd to last backup becomes last backup. @@ -123,6 +127,8 @@ if [ -f "$INPROGRESS_FILE" ]; then else PREVIOUS_DEST="" fi + # update PID to current process to avoid multiple concurrent resumes + echo "$$" > "$INPROGRESS_FILE" fi fi @@ -213,7 +219,7 @@ while : ; do fn_log_info "Running command:" fn_log_info "$CMD" - touch -- "$INPROGRESS_FILE" + echo "$$" > "$INPROGRESS_FILE" eval $CMD # ----------------------------------------------------------------------------- From 2f64db5973b5f1b13221d391076967b5a55dbb7a Mon Sep 17 00:00:00 2001 From: uglygus Date: Sat, 4 Apr 2015 07:50:11 -0400 Subject: [PATCH 10/11] PID reuse Checks for PID and $APPNAME in the results from pgrep in order to avoid the problem where the PID from a previous run has been recycled by another process. This caused us to exit even though we are not currently running. --- rsync_tmbackup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh index 553dcd6..0105ee1 100755 --- a/rsync_tmbackup.sh +++ b/rsync_tmbackup.sh @@ -113,7 +113,7 @@ fi # ----------------------------------------------------------------------------- if [ -f "$INPROGRESS_FILE" ]; then - if pgrep -F "$INPROGRESS_FILE" > /dev/null 2>&1 ; then + if pgrep -F "$INPROGRESS_FILE" "$APPNAME"> /dev/null 2>&1 ; then fn_log_error "Previous backup task is still active - aborting." exit 1 fi From 73dce717dff39f9465d5b7275e220a4c086f6f8a Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Fri, 25 Sep 2015 00:05:03 +0200 Subject: [PATCH 11/11] Removed broken Bitdeli badge and updated date --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index d03df91..973f8b5 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ An optional exclude file can be provided as a third parameter. It should be comp The MIT License (MIT) -Copyright (c) 2013-2014 Laurent Cozic +Copyright (c) 2013-2015 Laurent Cozic Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -75,5 +75,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/laurent22/rsync-time-backup/trend.png)](https://bitdeli.com/free "Bitdeli Badge")