all repos — dotfiles-extra @ d8e4339a351e8556ffe76d3c79be8c8fafa9cd66

extra configs that may be extraneous and/or may be platform specific

bin/backer-upper-0.7.5

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
#!/usr/bin/env bash

# by x1phosura

# Synchronizes the destination to the source, preserving metadata (owner, 
# group, permissions, timestamps, etc...) and symbolic links. It also skips
# replacing files based on a calculated checksum, which can save a lot of time
# with backups! ssh is used for encryption, and the script displays the sync
# progress with what SHOULD be human-readable numbers.
#
# Does NOT need to be run with sudo (and shouldn't).

echo "Enter the username for the remote machine: "
read ruser
echo "Enter the hostname (if DNS) or IPv4 address for the remote machine: "
read rhost

# '-a' preserves attributes like permissions, owner/group, and more, '-v' is
# verbose, '-h' is "human readable", and '-c' compares files to-be synced/
# transfered, if already existing, by checksum (rather than by filesize or
# modified time). '-e' specifies the remote shell to use, which here is ssh
# '--stats' and '--progress' simply show a lot of info about the file transfers
# '-z' compresses data during the transfer
options="-avhcz -e ssh --stats --progress"

echo "Delete files at destination not present in source directories? (y/n):"
read del_remote

if [ "$del_remote" = "y" ]; then # TEST THIS OPTION OUT BEFORE USE!!
    # '--delete' deletes files at the destination that are NOT present from the
    # source. USE CAREFULLY!! '--force' modifies '--delete' to handle something
    # do to with non-empty directories being deleted or overridden, so I'm 
    # guessing I want it
    echo "Extraneous files found in destination will be deleted."
    options="$options --delete --force"
elif [ "$del_remote" = "n" ]; then
    echo "Extraneous files found in destination will be kept."
else
    echo "Error: expected 'y' or 'n' character as input. Aborting for safety..."
    exit 1
fi


# Note: as they currently stand, DO NOT add trailing slashes to these
# filenames!! Why? Here is the best explanation I've seen as to how trailing
# slashes work in rsync:
# Without a slash on the source directory means copy both the source 
# directory, and the contents (recursively if specified) to the destination
# directory while adding a trailing slash means only copy the contents of
# the source directory, recursively if specified, to the destination.
# TODO: auto-generate paths (or read from textfile) instead of hardcoding
filelist="$HOME/73h4x \
$HOME/Documents \
$HOME/Downloads \
$HOME/OSes \
$HOME/Library \
$HOME/Subgenius \
$HOME/temp"

# Command structure:
# rsync $options src/dir1 src/dir2... "$ruser"@"$rhost":dest/dir/

# copy from here TO a remote destination
rsync $options $filelist "$ruser"@"$rhost":~/

# copy from a remote destination TO here (TODO)