Quote:
Originally Posted by nynaevelan
hmmm that sounds interesting, any chance you will wanna share?? Is this syncing within Calibre or to your hard drive??
|
To the hard drive. It's a linux shellscript, though it could still be used on Windows if you install rsync with
cygwin:
Code:
#!/bin/bash
## Set defaults
backup_folder="$HOME/Kindle Stuff/Kindle Backups/"
backup_excludes=.rsync-backup-exclude
restore_excludes=.rsync-restore-exclude
##### Declare usage
usage()
{
cat <<- _EOF_
Usage: kindlesync [OPTIONS]
Back up contents of Kindle drive as Kindle.rsync
Does not include system info or TTS
Deletes:
Personal Letters
EndActions
.fuse and .goutputstream garbage
OPTIONS
--backup-excludes
optional excludes file for backup
defaults to: '$backup_excludes'
--restore-excludes
optional excludes file for restore
defaults to: '$restore_excludes'
-f, --folder chooses backup folder, defaults to:
'$backup_folder'
-b, --backup perform backup only
-r, --restore perform restore only
-d, --dry-run backup, then do restore in test mode
-h, --help show this usage message then exit
_EOF_
}
##### Test for interactive options
## By default, all switches turned off
backup_only=
restore_only=
dry_restore=
while [ "$1" != "" ]; do
case $1 in
-h|--help) usage
exit
;;
-f|--folder) shift
backup_folder=$1
;;
--backup-excludes) shift
backup_excludes=$1
;;
--restore-excludes) shift
restore_excludes=$1
;;
-b|--backup) backup_only=1
;;
-r|--restore) restore_only=1
;;
-d|--dry-run) dry_restore=1
;;
*) echo "kindlesync: unrecognized option '$1'"
echo "Try 'kindlesync --help' for more information."
exit 1
esac
shift
done
##### Declare Functions
do_backup()
{
rsync -amv --exclude-from=$backup_excludes /media/Kindle/ ./Kindle.rsync
}
do_restore()
{
rsync -amv --exclude-from=$restore_excludes --delete ./Kindle.rsync/ /media/Kindle
}
do_dry_restore()
{
rsync -amv --dry-run --exclude-from=$restore_excludes --delete ./Kindle.rsync/ /media/Kindle
}
################################################################################################
##### OLD SYNC ONLY DOCUMENTS FOLDER ###########
##### ###########
##### rsync -amv --exclude-from=.rsync-exclude /media/Kindle/documents/ ./documents ###########
##### rsync -amv --delete ./documents/ /media/Kindle/documents ###########
################################################################################################
#### MAIN
if [ ! -d /media/Kindle/ ]; then
echo "Your Kindle is not plugged in."
exit 1
fi
cd "$backup_folder"
if [ "$backup_only" = "1" ]; then
echo "Backing up to: $(pwd)/Kindle.rsync"
do_backup
elif [ "$restore_only" = "1" ]; then
echo "Restoring..."
do_restore
elif [ "$dry_restore" = "1" ]; then
echo -e "Backing up to: $(pwd)/Kindle.rsync\n\n"
do_backup
echo -e "Simulating restore; this isn't really happening.\n\n"
do_dry_restore
else
echo -e "Backing up to: $(pwd)/Kindle.rsync\n\n"
do_backup
echo -e "Restoring...\n\n"
do_restore
fi
the backup-excludes file looks like this:
Code:
#DOCUMENTS JUNK#
- Personal\ letter*
- .fuse*
- .goutputstream-*
- EndActions*
- *.partial
#SYSTEM#
+ /system/
+ /system/thumbnails/
+ /system/thumbnails/*
- /system/*
#TTS#
- /tts/
#Sandbox#
- /.active_content_sandbox/
The restore-excludes file looks like this:
Code:
- /tts/
- /.active_content_sandbox/
- /documents/*.partial
#SYSTEM#
+ /system/
+ /system/thumbnails/
+ /system/thumbnails/*
- /system/*