This article explains how to make your backup script reliable over both USB and WLAN connections and across software updates.
Backups over USB
Backing up files over USB is as simple as typing the following command on your terminal:
scp -r root@10.11.99.1:/home/root/.local/share/remarkable/xochitl/* /path/to/backup/directory/
Reliable backups across software updates
reMarkable tablets have two partitions and use only one at a time. The one in use has the current version of the software, while the other, inactive part has the previous version. When the system updates, it does so by replacing the old software on the inactive partition with the new software, the tablet then shuts down and reboots into this partition and runs the new software. The "current software" on the first partition is now, of course, no longer current, therefore when another update comes around this partition is the one whose software will be replaced.
What this means is that the tablet switches back and forth between these partitions, whose IP addresses differ by 1, thereby creating this change of +/-1 after updates. My IP address, for example either ends in 195 or 196 depending on which partition is being used.
This is all a minor inconvenience to our backup script as it means that if it works during one update it will not work during the next, but it will work again after a second update.
The simple solution is therefore to check for a change to the IP address while attempting to connect to the tablet, if one IP address fails, try adding one, if that fails try substracting 1. Finally, if all else fails, report an error.
Since we may wish to have the option to backup our files over USB (as it is faster) it is a good idea to try it first and resort to a WLAN connection if it fails.
#!/bin/bash
USB_ADDRESS=10.11.99.1
IP_ADDRESS=192.168.0.195
REMARKABLE_DIRECTORY=/home/root/.local/share/remarkable/xochitl/
BACKUP_DIRECTORY=/path/to/backup/directory/
rmcp() {
scp -r root@$IP_ADDRESS:$REMARKABLE_DIRECTORY/* $BACKUP_DIRECTORY
}
if usb_connected()
IP_ADDRESS=$USB_ADDRESS
rmcp
exit
else
rmcp # Try with expected IP address
else if IP_ADDRESS+=1
rmcp
else if IP_ADDRESS-=1
rmcp