My config files for Syncthing, a continuous file synchronization program. Only non-sensitive data (folder and device IDs).
This repo tracks the Syncthing config files of my phone and my laptops.
I sync some folders of my home directory between my laptops, and some folders of my phone.
Usual folders:
Custom folders:
Current Android versions only grants Syncthing read-only access to the SD card, so I store all my data in the internal storage. I set dummy folders anyways in case Android 11 allows Syncthing to write to the SD card.
Get the latest stable release.
curl -s https://api.github.com/repos/syncthing/syncthing/releases/latest \
| grep "browser_download_url.*tar.gz" | grep "linux-amd64" \
| cut -d '"' -f 4 \
| wget -i - -O syncthing-latest.tar.gz
Extract its contents and create a local symlink to the binary.
mkdir -p syncthing-latest
tar -xf syncthing-latest.tar.gz -C syncthing-latest/ --strip-components=1
rm syncthing-latest.tar.gz
ln -srf syncthing-latest/syncthing ~/.local/bin/
Syncthing overwrites the config file instead of editing it, so neither symlinks nor hardlinks from the config files to the repo will work. A workaround to track those files is to mount their parent directories in folders created inside the repo, stage the config.xml files and use the .gitignore to ignore files containing sensitive data.
The following steps uses paths of my machine for sake of example.
Syncthing store the config files in ~/.config/syncthing/
, mount this folder inside the repo to track its contents.
mkdir -p ~/code/syncthing-config/desktop-config/
sudo mount --bind ~/.config/syncthing/ ~/code/syncthing-config/desktop-config/
If using Nemo, run the following script to hide “link” emblems and show Syncthing emblems on the synced folders.
./emblems.sh
In case you want to restore the default emblems, run:
./restore-emblems
Use “Import and Export” in the app settings to store a backup of the config files in [internal data]/backups/syncthing/
. I sync this folder with my computer in ~/mobile/DEVICE/int-syncthing
.
mkdir -p ~/code/syncthing-config/android-config/
sudo mount --bind ~/mobile/ga50/int-syncthing/ ~/code/syncthing-config/android-config/
If everything works as intended, edit /etc/fstab
with:
...
/home/USER/.config/syncthing/ /home/USER/code/syncthing-config/desktop-config/ none user,nodev,x-gvfs-hide,bind 0 0
/home/USER/mobile/DEVICE/int-syncthing/ /home/USER/code/syncthing-config/android-config/ none user,nodev,x-gvfs-hide,bind 0 0
The .gitignore
contains the list of files and folders that must not be tracked:
Only folder and device IDs can be tracked, those IDs are stored in the config.xml
files. However, these files include API keys. What I did was commit blank config.xml
files, then pasted and committed the lines with non-sensitive data and lastly I added the sensitive data to the files but didn’t commit them. I mantain the repo using a pre-commit hook to avoid commiting lines with API keys:
ln -srf pre-commit .git/hooks/
Make sure to unstage lines containing sensitive data.