Skip to content

Instantly share code, notes, and snippets.

@randomcamel
Created June 14, 2021 16:59
Show Gist options
  • Select an option

  • Save randomcamel/8e5a8f72a163236768267e9ca7ae4dc1 to your computer and use it in GitHub Desktop.

Select an option

Save randomcamel/8e5a8f72a163236768267e9ca7ae4dc1 to your computer and use it in GitHub Desktop.

Revisions

  1. randomcamel created this gist Jun 14, 2021.
    15 changes: 15 additions & 0 deletions versioned-backup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #!/bin/sh

    # uses rsync's hard-link feature to mimic the function and structure of Apple's Time Machine.

    # my server's name is 'shiny', which I evidently used to mount on /backup.
    TARGET=/backup/shiny

    date=`date "+%Y-%m-%dT%H:%M:%S"`
    rsync --exclude=.AppleDouble -aCPv --link-dest=$TARGET/current $HOME $TARGET/back-$date
    cd $TARGET
    rm current
    ln -s back-$date current

    # I had this disabled, but it was a nice touch.
    touch $TARGET/../.last-rsync