Backing up ChromeOS using Syncthing and inSync

Backing up ChromeOS using Syncthing and inSync

I've recently run into a scenario using ChromeOS which is kind of annoying, however i've found a workaround which works for me. This might help someone else.

Scenario

I have a Google account which is linked directly to my Chromebook, this means i can in the Files app see my google Files and backup these files to my Google Drive account.

I also however have a Google Workspace Account, this too has its own Google Drive capability

On the Chromebook while I can swap in the browser between Google Drive and Google Workspace Drive, the Files app doesn't yet allow me access to both Google Drives.

I want to use the services and applications linked to my Google account and have the ability to ensure all the files I create on the Chomebook are backed up to Google Workspace.

Problem

While you can connect multiple Google accounts to the Chromebook, only the primary account (ChromeOS 87) is seen as a mounted Drive instance on the Files app so its not possible to see and therefore backup files to a second google account.

Solution

The solution to this is workable, automated, simple to setup and can be portable to a point too. and is based on

ChromeOS Linux Containers
Port Forwarding
Syncthing
inSync

At a high level the solution looks like this

While i'm using a Mac as the conduit sync thing runs on other OS's and is in fact far more fully featured than the use case i'm going to cover here. I tend to use the Mac as a personal server now i've moved to using the Chromebook more

So how does this fit together?

ChromeOS install

Lets start with the ChromeOS device and it needs the Linux Shell up and running. I covered how to do this in a previous post

Tips and Tricks for ChromeOS
VersionDateVersionChangedNotes12 Jan 20211.0.0First PostAs someone who has been usingChromebooks well before the Android Apps and Linux shell were a thing. I can saythat they have come a long way since those early days. One thing I’ve learned over all this time is to change my workflow away f…

Under the section "Enable the Shell"

Once enabled install SyncThing

# Add the "stable" channel to your APT sources:
echo "deb https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list
Optional
The candidate channel is updated with release candidate builds, usually every second Tuesday of the month. These predate the corresponding stable builds by about three weeks.
# Add the "candidate" channel to your APT sources:
echo "deb https://apt.syncthing.net/ syncthing candidate" | sudo tee /etc/apt/sources.list.d/syncthing.list

Then proceed with the following steps to finish setting up the chosen track and install Syncthing.

# Add the release PGP keys:
curl -s https://syncthing.net/release-key.txt | sudo apt-key add -

# Increase preference of Syncthing's packages ("pinning")
printf "Package: *\nPin: origin apt.syncthing.net\nPin-Priority: 990\n" | sudo tee /etc/apt/preferences.d/syncthing

# Update and install syncthing:
sudo apt-get update
sudo apt-get install syncthing

Before Syncthing is started it needs to be set to listen publically on 0.0.0.0 and not locally on 127.0.0.1

nano ~/.config/syncthing/config.xml

Find the line

<address>127.0.0.1:8384</address>

Change it to

<address>0.0.0.0:8384</address>

Save the File (ctrl + O)

Exit (ctrl + X)

Start the services

sudo systemctl enable syncthing@${USER}.service
sudo systemctl start syncthing@${USER}.service
sudo systemctl status syncthing@${USER}.service

The service is up and running and listening on the containers outward facing IP Address, however to allow Chrome to see the Syncthing service page port forwarding needs to be enabled

Open Settings and search for Port Forwarding

Add Port 8384 TCP with a label of Syncthing this will punch a hole from chromeOS and the rest of the lan into the container

Head to the browser on the Chromebook and open

http://penguin.linux.test:8384/

Which should open

Yours will only have the default folder (not myconfigs)

Syncthing is now installed on your Chromebook and available on your lan.

Apple Install

To give Syncthing something to sync with it needs another Syncthing, you could do this on Debian/Ubuntu and just repeat the apt install instructions above.

I happen to have a MacBook Pro I can use

Syncthing

If you're not running Homebroew on your Mac, why not? Its a great way of not just installing software bue ensuring its well maintained as well. Syncthing can be installed as a HomeBrew app.

Installation
Documentation for the missing package manager for macOS.

the basics to install homebrew are

mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew

However check out the link aboe as these may change

Once installed, installing syncthing is as simple as

brew install syncthing
brew services start syncthing

This will install Syncthing on OSX and ensure it starts after a reboot

Note:

If like me, you're going to manage Syncthing from the Mac, you can leave the config as is, if you'd like to be able to access the Mac Syncthing interface on your lan then

nano ~/.config/syncthing/config.xml

Find the line

<address>127.0.0.1:8384</address>

Change it to

<address>0.0.0.0:8384</address>

then run

    brew services restart syncthing

Syncthing is now installed on the Mac and can be opened using

http://<mac ip address>:8384

Insync

I use inSync as my sync between Google Workspace Drive and my Mac, there is a google Sync tool and that is free and can also be used. I have used inSync for a long time on Linux and it works well on OSX too.

Insync - Google Drive & OneDrive Syncing on Linux, Windows & Mac
Give all your computers & files the power of Google Drive & OneDrive. Sync, use & share your files directly from Explorer, Nautilus, Caja, Nemo & Finder.

As a Mac user the isntall is pretty painless

  • Download the App
  • Open the DMG
  • Drag the app to Applications
  • Open Applications
  • Open the App
Yes, this is ubuntu not a Mac, but the scame screens and look and feel exist

Link insync to the Google Workspace account and tell it what you want  to sync and you're done. It will sit there and sync any new files up to Google that hit the directory you choose.

Setup

The stage has been reached where all the software is installed Syncthing is running on the Chromebook and the Mac, Insync is running too.

Syncthing needs to be setup and before this post continues its worth noting again this is only a subset of what Syncthing can do. I'm only interested in a 1 way data flow from My chromebook, to my Mac to Google Workspace Drive. It is possible to sync everything both ways, to multiple devices create versioned files and a whole lot of other options.

Setup SyncThing on Chromebook

Before we setup sync thing, we need to make sure that the folder created in ChromeOS is viable to the Linux shell

Ive setup a folder called work

Right click on this folder and select Share with Linux

Note:
If Share with Linux is not available and Manage Linux sharing displays it means that a folder above this one is already shared with linux

In my case I share the Whole My Files folder with the linux container wich i view as follows:

ls /mnt/chromeos/MyFiles/work/

ChromeOS  Work
Note:
the defaults mountpoints are /mnt/chromeos for the hard disk or /mnt/etxternal for any external devices like usb sticks.

Knowing this information we can setup a folder to share in Syncthing

Under Folders click Add Folder

Provide the

  • Folder Label
  • Folder Path

Lease the Folder ID as the random characters

Click on the Sharing Tab

Its possible the other Syncthing server has now broadcast its presence, if it has, click on the tick next to it.

Click on File Versioning

For this example i'm not going to use any versioning

Click on Ignore Patterns

These are useul if you don't want ot sync large files like ISO images or Virtual file disks.

Click on Advanced

Under Folder Type i've selected Send only from the Drop down as i'm not interested in pulling files onto the Chromebook, only pushing them to the Mac.

At this point I am done and I click on Save

I have a new Folder called chromeos - work and when i open the folder i can see the information about it.

Setup SyncThing on Mac

Over on the Mac Syncthing interface

Note:
You may see a banner on the top of the screen asking if you accept the job on this server, as long as this is a job you are aware of setting up on a server you set it up on it is ok to say yes

If I expand the link for chromeos-work

We can see that the local mac has a folder called ~/chromeos-work

If i click on Edit and select the Advanced tab i can also set the folder to be recieve only.

This contains the sync files from my Chromebook.

Setup InSync

Now we know the base file on the Mac if InSync is set as ~/chromeos-work as a base folder it will sync the files from this folder up to Google Workspace Drive.

This has allowed me to have my files backed up from the Chromebook to

  • Google Drive
  • Mac Server
  • Google Workspace

Conclusion

I appreciate for many this will be of little use, however it does show  that with a little thought most problems can be solved and it also shows that Syncthing on chromeOS has the ability to not only be used but also help sync files around your home lan.

I've expanded this out further to backup photos, videos and publish photos by syncing them to a specific drive on a server.


Share Tweet Send
0 Comments
Loading...