Skip to content

Instantly share code, notes, and snippets.

@lionicsheriff
Last active January 1, 2016 22:59
Show Gist options
  • Save lionicsheriff/8213315 to your computer and use it in GitHub Desktop.
Save lionicsheriff/8213315 to your computer and use it in GitHub Desktop.
Backup kindle books (from the kindle itself). For use in cron.
#!/bin/sh
SSID="YOUR WIRELESS SSID"
REMOTE_LOCATION="rsync://SERVER/module"
# wake up. Not sure if this is neccessary
# will error if already awake
lipc-set-prop com.lab126.powerd wakeUp 1
# start wireless
lipc-set-prop com.lab126.cmd wirelessEnable 1
# check if the kindle is connected to the correct wireless network
if iwconfig wlan0 | grep -q "ESSID:\"$SSID\""
then
# send the books over
# NOTE: does not delete removed books
rsync -q -a /mnt/us/documents "$REMOTE_LOCATION"
fi
# go back to sleep
# again, not sure if necessary
lipc-send-event com.lab126.powerd.debug dbg_power_button_pressed
@lionicsheriff
Copy link
Author

  • Tested with Kindle Touch
  • rsync comes with USBNetworking when jailbreaking. It seems to have a bit of trouble with the ssh protocol (probably no client installed) but plain rsync works.

@lionicsheriff
Copy link
Author

Might be a good idea to create a new user so it has a separate crontab than the one provided by amazon (and less likely to be overwritten by an update)

/etc/crontab/root

#*/15 * * * * /usr/sbin/checkpmond                                             
*/15 * * * * /usr/sbin/tinyrot                                                 
*/60 * * * * /usr/sbin/loginfo tmpfs                                           
*/60 * * * * /usr/sbin/loginfo localVars                                       
*/60 * * * * /usr/sbin/loginfo userstore                                       
*/60 * * * * /usr/sbin/loginfo memusedump                                      
*/15 * * * * /usr/sbin/loginfo powerdcheck                                     
#*/30 * * * * _OTAFILE=`ls /mnt/us/[Uu]pdate*.bin`;  if [ $? -eq 0 ]; then /usr

# backup books                                                                 
* 5 * * * /mnt/us/backup.sh

@lionicsheriff
Copy link
Author

Turns out the kindle sleeps deeper than I thought. Going to move it to trigger when the power button gets pressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment