Skip to content

Instantly share code, notes, and snippets.

@videogramme
Created March 29, 2015 12:05
Show Gist options
  • Save videogramme/02f64c4fa4e4208e9449 to your computer and use it in GitHub Desktop.
Save videogramme/02f64c4fa4e4208e9449 to your computer and use it in GitHub Desktop.

Revisions

  1. videogramme created this gist Mar 29, 2015.
    26 changes: 26 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    ### https://linuxfr.org/forums/general-cherche-logiciel/posts/resolu-backup-oui-c-est-une-vielle-problematique ###

    #!/bin/sh
    date=`date "+%Y%m%d-T%H%M%S"`

    # Attention au /
    SOURCE_DIR=/home/denis/
    TARGET_HOST=192.168.0.4
    TARGET_USER=rsync
    TARGET_DIR=/volume1/persosave/rsync/denis



    time rsync --archive --one-file-system --hard-links \
    --human-readable --inplace \
    --partial --progress \
    --delete-excluded \
    --exclude-from=$SOURCE_DIR/script/rsync-exclude \
    --link-dest=$TARGET_DIR/current \
    $SOURCE_DIR $TARGET_USER@$TARGET_HOST:$TARGET_DIR/incomplete_back-$date

    if [ $? -eq 0 ]; then
    ssh $TARGET_USER@$TARGET_HOST "mv $TARGET_DIR/incomplete_back-$date $TARGET_DIR/back-$date \
    && rm -f $TARGET_DIR/current \
    && ln -s back-$date $TARGET_DIR/current";
    fi