Chrome browsers use “Chrome Sync” to constantly sync most of the critical user settings/bookmarks with the Cloud and this is what allows users to switch between Chromebooks and still allow them to continue where they left off.
You can also choose to use Google Drive instead of local Download folder to sync files to the cloud as well.
But, the user data in the “Crostini” side of Chromebook is not currently synced with the cloud and it may never be in future. But you can do it all yourself using an opensource tool called Unison.
How does Unison work ?
Unison works a bit like “rsync“, which allows one to copy files from one device to another using a secure ssh tunnel. But its different from rsync because it allows two-way syncs between two devices. And it can be expanded to allow syncing between more than two devices as well.
The tool requires an initial sync (like the way rsync is done), but after that one could use a cronjob to keep data in sync.
Requirements for Unison on Chromebook
Here are some basic things you will need to setup Unison:
- Basic experience using linux and ssh – This is going to be important because unison is an open source program which doesn’t come with support, so you will end up having to support yourself when you hit problems.
- A Chromebook capable of running Crostini – You can find one here if you don’t own it. I strongly recommend getting something with 8GB or more Ram for Crostini.
- A linux host in the cloud which is active 24/7, can be connected via SSH and has sufficient storage to backup your Chromebook – I use GCE which is only about $3 per month if you go with the smallest server. But you could use pretty much anything including your own personal server running from your basement.
Setting up Unison
Step 1: Get the required base packages installed
Install base packages
apt-get -y install rsync apt-get -y install cron
Step 2: Install Unison
Unison hasn’t made it to the package management system I was using and hence I was forced to look for binaries published elsewhere. I chose to trust the binaries unison has made available. Depending on how much you trust it, and whether you have the time and experience to build it yourself, you could choose to build it from source as well.
The key thing to note is that you should try to use the same exact binary on both sides else you may have trouble syncing your files.
Step 3: Identify where you are going to keep all your files.
I kept my unison binaries under ~/unison-binaries across all systems, and kept the rest of my files to sync under ~/unison. And I synced this folder across all my devices. You can pick a different one if you want
Step 4: Create your config file of how you want this to work
Create ~/.unison/default.prf on both client and server with the following contents.
root=/home/bob/unison root=ssh://firstname.lastname@example.org//home/bob/unison auto=true batch=true confirmbigdel=true fastcheck=true group=true owner=true prefer=newer silent=true times=true servercmd=/home/bob/unison-binary/bin/unison
Step 5: Do the first unison sync from your chromebook to the cloud
~/unison-binary/bin/unison -ignorearchives -servercmd=/home/bob/unison-binary/bin/unison ssh://email@example.com//home/bob/unison /home/bob/unison Step 6: Setup cron to sync every 5 minutes
*/5 * * * * /home/bob/unison-binary/bin/unison > /tmp/unison.out 2> /tmp/unison.err
Step 7: Add unison to .profile to do a sync every time you start your session
echo "/home/bob/unison-binary/bin/unison" >> ~/.profile
Challenges you may notice using Unison on Chromebooks
- The files are not in sync all the time. If you try to edit the same file two different places, they will get out of sync and you may end up in a state where Unison may not know how to deal with it. As a policy only edit your files on one device.
- Unison uses “hostname” to identify different entities syncing with each other. If you have multiple laptops with the same exact name, Unison may get confused. To resolve this you should update your hostname by editing “/etc/hostname” and keeping it unique across your fleet.
I’ve been using Unison on my Chromebook for a few weeks now without any issues. I have two chromebooks of which only one is in active use. I’ve been using this setup to build and test the scripts behind my Chrome Device List website and I haven’t had much issues. I plan to expand this setup a bit to use my Chromebooks as a backup for my blog as well.
If you experiment with Unison, or have similar experiences with a different tool, please let me know in the comments.
Leave a Reply