#!/bin/bash
# /usr/local/bin/sync001
# http://crystalfaeries.net/posix/bin/sync001
# celeste:crystalfaery 2014-08-20 19:03:58+00:00
cd $HOME # there is no place like om
#mail_tidy # sync addressbook, e-mail, rss-feeds; then the rest of /home/`whoami` directory:
retain=6 # how long to retain size 0 mailboxes to ensure that deletions propogate amongst all synchronized hosts
if [ $# == 0 ]
then
dryrun="" # do it for real
else # total hack accepting ANY argument as meaning --dry-run
dryrun="--dry-run" # only testing
echo "$0 DEBUG: ANY Argument means do a Dry-Run" 1>&2
fi
# sync with my_twin
cd $HOME || exit -1
touch Mail/.mail_tidy # synchronization time stamp
#echo "rsync -auvzH $dryrun `my_twin`:~/Mail ~"
#rsync -auvzH $dryrun `my_twin`:~/Mail ~
#echo "rsync -auvzH $dryrun ~/Mail `my_twin`:~"
#rsync -auvzH $dryrun ~/Mail `my_twin`:~
echo "rsync -auvzH $dryrun `my_twin`:~/.abook ~"
rsync -auvzH $dryrun `my_twin`:~/.abook ~
echo "rsync -auvzH $dryrun --exclude=.muttrc.local --exclude=.muttheaders ~/.abook ~/.mutt* `my_twin`:~"
rsync -auvzH $dryrun --exclude=.muttrc.local --exclude=.muttheaders ~/.abook ~/.mutt* `my_twin`:~
echo "rsync -auvzH $dryrun --exclude=.muttrc.local --exclude=.muttheaders `my_twin`:~/.mutt* ~"
rsync -auvzH $dryrun --exclude=.muttrc.local --exclude=.muttheaders `my_twin`:~/.mutt* ~
echo "rsync -auvzH $dryrun ~/.feed2imaprc `my_twin`:~/.feed2imaprc"
rsync -auvzH $dryrun ~/.feed2imaprc `my_twin`:~/.feed2imaprc
echo "rsync -auvzH $dryrun `my_twin`:~/.feed2imaprc ~/.feed2imaprc"
rsync -auvzH $dryrun `my_twin`:~/.feed2imaprc ~/.feed2imaprc
echo "rsync -auvzH $dryrun ~/.*.triweekly.txt `my_twin`:~"
rsync -auvzH $dryrun ~/.*.triweekly.txt `my_twin`:~
echo "rsync -auvzH $dryrun `my_twin`:~/.*.triweekly.txt ~"
rsync -auvzH $dryrun `my_twin`:~/.*.triweekly.txt ~
# cannot keep a bitcoin wallet on an insecure host:
# echo "rsync -auvzH $dryrun ~/.bitcoin/wallet.dat `my_twin`:~/.bitcoin"
# rsync -auvzH $dryrun ~/.bitcoin/wallet.dat `my_twin`:~/.bitcoin
# echo "rsync -auvzH $dryrun `my_twin`:~/.bitcoin/wallet.dat ~/.bitcoin"
# rsync -auvzH $dryrun `my_twin`:~/.bitcoin/wallet.dat ~/.bitcoin
# tidy: delete empty mailboxes we likely will not reuse, keeping certain ones even if empty
cd ~/Mail || exit -1
echo -n "Deleting Empty Mailboxes:" 1>&2
for f in $(find . -size 0 -mtime +$retain \! -name .mail_tidy | sed 's/^\.\///');do # we have a list of special folders to keep even if empty:
case "$f" in
sent)
;; # sent e-mails
sent-mail)
;; # sent e-mails
postponed)
;; # postponed = drafts
templates)
;; # templates for outgoing e-mails
calendar)
;; # scheduled items with specific dates
download)
;; # CONTENTS WILL BE DESTROYED BY DOWNLOADER
*)
echo -n " $f" 1>&2 # notify the human as we delete...
if [ "$dryrun" == "" ]
then
rm ~/Mail/"$f" 2>/dev/null
# rm ~/documents/Mail/"$f" 2>/dev/null
# rm ~/documents-/Mail/"$f" 2>/dev/null
fi
;;
esac
done
echo " ;" 1>&2
rsync -auvzH --exclude=documents --exclude=documents- --exclude=mail --exclude=Mail `my_twin`:~/* ~
rsync -auvzH --exclude=documents --exclude=documents- --exclude=mail --exclude=Mail * `my_twin`:~
# backup /home/`whoami` directory:
rsync -auvzH --exclude=documents --exclude=documents- {.??,}* documents-/kahealani &
rsync -auvzH --exclude=documents --exclude=documents- {.??,}* documents/kahealani &
fg;fg # complete parallelism
syntax highlighted by Code2HTML, v. 0.9.1