profile-sync-daemon(1)

NAME
profile-sync-daemon - Symlinks and syncs browser profiles to RAM (tmpfs) thus reducing HDD/SSD calls and speeding-up browsers.

DESCRIPTION
Profile-sync-daemon (psd) is a tiny pseudo-daemon designed to manage browser profile(s) in tmpfs and to periodically sync back to the physical disc (HDD/SSD). This is accomplished by an innovative use of rsync to maintain synchronization between a tmpfs copy and media-bound backup of the browser profile(s). Additionally, psd features several crash recovery features.

Design goals of psd:

    •   Completely transparent user experience.

    •   Reduced wear to physical discs (particularly SSDs).

    •   Speed.

Since the profile(s), browser cache*, etc. are relocated into tmpfs (RAM disk), the corresponding onslaught of I/O associated with using the browser is also redirected from the physical disc to the RAM, thus reducing wear to the physical disc and also greatly improving browser responsiveness. For example, the access time of RAM is on the order of nanoseconds while the access time of physical discs is on the order of milliseconds. This is a difference of six orders of magnitude or 1,000,000 times faster.

*Note that some browsers such as Chrome/Chromium, Firefox (since v21), Midori, and Rekonq actually keeps their cache directories separately from their browser profile directory. It is not within the scope of profile-sync-daemon to modify this behavior; users wishing to relocate this directory, may refer to the following url for several work-arounds: https://wiki.archlinux.org/index.php/Chromium_Tips_and_Tweaks#Cache_in_tmpfs

ABOUT SYSTEM PRIVACY
Psd uses system tmpfs which is likely world-readable. It is therefore recommended that permissions on profile(s) should be set to 700 to retain privacy. Psd will honor the permissions set on the profile even if they too are world-readable. Running psd in parse mode (see below) will warn if these are not set to 700 but it is ultimately your choice.

SETUP
/etc/psd.conf contains all user managed settings.

WARNING -- Any edits made to /etc/psd.conf while psd is running will be applied only after psd has been restarted from the init service.

    •   At a minimum, define which user(s) will have their profiles managed by psd in the USERS array. Note that at least one user must be defined.

    •   Optionally uncomment and define which browsers are to be managed in the BROWSERS array. Note that the default is all browsers unless otherwise defined.

    •   Optionally define the location of your distro's tmpfs. Do this in the VOLATILE variable.

    •   Optionally define the location of your distro's /run. Do this in the DAEMON_FILE variable.

    •   Optionally enable the use of overlayfs to improve sync speed even further and use a smaller memory footprint. Do this in the USE_OVERLAYFS variable. Note that this option requires your kernel be configured to use either the 'overlay' or 'overlayfs' module. See the FAQ below for additional details on this feature.

    •   Optionally disable the use of crash-recovery snapshots. Do this in the USE_BACKUPS variable.

RUNNING PSD

  PREVIEW MODE
The preview (parse) option can be called to show users exactly what psd will do/is doing based on the entries in /etc/psd.conf as well printout useful information such as profile size, paths, and if any recovery snapshots have been created.

 $ psd p
 Profile-sync-daemon v5.65 on Arch Linux.
  Systemd service is currently active.
  Systemd resync service is currently active.
  Overlayfs v23 is currently active.
    Psd will manage the following per /run/psd.conf settings:

      browser/psname:  chromium/chromium
      owner/group id:  facade/100
      sync target:     /home/facade/.config/chromium
      tmpfs dir:       /tmp/facade-chromium
      profile size:    93M
      overlayfs size:  39M
      recovery dirs:   2 <- delete with the c option
       dir path/size:  /home/facade/.config/chromium-backup-crashrecovery-20150117_171359 (92M)
       dir path/size:  /home/facade/.config/chromium-backup-crashrecovery-20150119_112204 (93M)
      browser/psname:  firefox/firefox
      owner/group id:  facade/100
      sync target:     /home/facade/.mozilla/firefox/f8cv8bfu.default
      tmpfs dir:       /tmp/facade-firefox-f8cv8bfu.default
                        Permissions are 755 on this profile.
                        Recommend a setting of 700 for increased privacy!
      profile size:    145M
      overlayfs size:  13M
      recovery dirs:   none

  CLEAN MODE
The clean mode will delete ALL recovery snapshots that have accumulated. Run this only if you are sure that you want to delete them.

 $ psd c
 Profile-sync-daemon v5.65 on Arch Linux.
 Deleting 2 crashrecovery dirs for profile /home/facade/.config/chromium
  /home/facade/.config/chromium-backup-crashrecovery-20150117_171359
  /home/facade/.config/chromium-backup-crashrecovery-20150119_112204

  START AND STOP PSD FOR SYSTEMD USERS
Both a systemd service file and timer are provided, and should be used to start or stop psd.

The role of the timer is update the tmpfs copies back to the disk. This occurs once per hour by default. The timer is started automatically with psd.service.

 # systemctl [option] psd
Available options: start stop enable disable

  START AND STOP PSD OPENRC OR UPSTART
For distros not using systemd, using other init scripts to manage the daemon is highly recommended. Examples are provided and are known to work with Upstart and OpenRC. See the INSTALL document in the source tarball if using OpenRC or Upstart!

Note that for either of these, the supplied cron script (installed to /etc/cron.hourly) will run the resync option to keep the tmpfs copies sync'ed. Of course, the target system must have cron installed and active for this to happen.

SUPPORTED BROWSERS

•   Chromium (stable, beta, and dev)

•   Conkeror

•   Epiphany

•   Firefox (stable, beta, and aurora)

•   Firefox-trunk (this is an Ubuntu-only browser: http://www.webupd8.org/2011/05/install-firefox-nightly-from-ubuntu-ppa.html)

•   Google Chrome (stable, beta, and dev)

•   Heftig's version of Aurora (Arch Linux: https://bbs.archlinux.org/viewtopic.php?id=117157)

•   Icecat

•   Iceweasel

•   Inox (https://bbs.archlinux.org/viewtopic.php?id=198763)

•   Luakit

•   Midori

•   Opera (legacy, stable, next, and developer)

•   Otter-browser

•   Palemoon

•   QupZilla

•   Rekonq

•   Seamonkey

•   Vivaldi

•   Vivaldi-snapshot

  CAVEATS FOR FIREFOX AND ITS KIN
The way psd keeps track of browser profiles and sync targets requires users to have unique name as the last directory for all profiles in their respective $HOME/.mozilla/<browser>/profiles.ini. Psd will check for this and refuse to run if this condition is unsatisfied.

The following is an example of a BAD profile that will not pass the test. Note that although each full path is unique, they both END in the same name! Again, users must modify the profiles.ini and the corresponding directory on the filesystem to correct this.

 $ cat ~/.mozilla/firefox/profiles.ini
 [General]
 StartWithLastProfile=1
 [Profile0 for user facade]
 Name=normal
 IsRelative=0
 Path=/mnt/data/docs/facade/mozilla/firefox/myprofile.abc
 Default=1
 [Profile1 for user debbie]
 Name=proxy
 IsRelative=0
 Path=/mnt/data/docs/debbie/mozilla/firefox/myprofile.abc

SUPPORTED DISTROS
At this time, the following distros are officially supported but there is no reason to think that psd will not run on another distro:

    •   Arch Linux

    •   Chakra

    •   Debian (8+)

    •   Exherbo

    •   Fedora (18+)

    •   Gentoo

    •   Mint (18+)

    •   NixOS (14.04+)

    •   OpenSUSE

    •   Ubuntu (15.04+)

    •   Void Linux

It is HIGHLY recommended for users to use a distro-provided package of psd, see the project page linked below for the most up-to-date information and links.

FAQ
Q1: What is overlayfs and why do I want to use it?

A1: Overlayfs is a simple union file-system mainlined in the Linux kernel version 3.18.0. Starting with psd version 5.54, overlayfs can be used to reduce the memory footprint of psd's tmpfs space and to speed up sync and unsync operations. The magic is in how the overlay mount only writes out data that has changed rather than the entire profile. The same recovery features psd uses in its default mode are also active when running in overlayfs mode. Overlayfs mode is enabled by uncommenting the USE_OVERLAYFS= line and set it to "yes" in /etc/psd.conf followed by a restart of the daemon.

There are several versions of overlayfs available to the Linux kernel in production in various distros. Versions 22 and lower have a module called 'overlayfs' while newer versions (23 and higher) have a module called 'overlay' -- note the lack of the 'fs' in the newer version. Psd will automatically detect the overlayfs available to your kernel if it is configured to use one of them.

See the example in the PREVIEW MODE section above which shows a system using overlayfs to illustrate the memory savings that can be achieved. Note the "overlayfs size" report compared to the total "profile size" report for each profile. Be aware that these numbers will change depending on just how much data is written to the profile, but in common use cases, the overlayfs size will always be less than the profile size.

Q2: How do I load the overlay or the overlayfs module?

A2: Simply call /usr/bin/modprobe to load the module (as root) to load it. Again, try 'overlay' first, but if modprobe is unable to locate that module, try 'overlayfs' as a fallback. Note that using modprobe to load the module will NOT reload the module on the next boot. The recommended method to have the needed module load automatically at boot is to place it in /etc/modules-load.d/load_me.conf (the file should contain a single word consisting of just the module name).

Q3: My system crashed and psd didn't sync back. What do I do?

A3: Odds are the "last good" backup of your browser profile(s) is just fine still sitting happily on your filesystem. Upon restarting psd (on a reboot for example), a check is preformed to see if the symlink to the tmpfs copy of your profile is invalid. If it is invalid, psd will snapshot the "last good" backup before it rotates it back into place. This is more for a sanity check that psd did no harm and that any data loss was a function of something else.

Q4: Where can I find this snapshot?

A4: It depends on the browser. You will find the snapshot in the same directory as the browser profile and it will contain a date-time-stamp that corresponds to the time at which the recovery took place. For example, a chromium snapshot will be ~/.config/chromium-backup-crashrecovery-20130912_153310 -- of course, the date_time suffix will be different for you.

Q5: How can I restore the snapshot?

A5: Follow these steps:

    1.  Stop psd.

    2.  Confirm that there is no symlink to the tmpfs browser profile directory. If there is, psd did not stop correctly for other reasons.

    3.  Move the "bad" copy of the profile to a backup (don't blindly delete anything).

    4.  Copy the snapshot directory to the name that browser expects.

    Example using chromium:

    1.  mv ~/.config/chromium ~/.config/chromium-bad

    2.  cp -a ~/.config/chromium-backup-crashrecovery-20130912_153310 ~/.config/chromium

At this point, launch chromium which will use the backup snapshot you just copied into place. If all is well, it is safe to delete the snapshot. Remember, to start psd, no browsers must be open (or psd will refuse to start).

Q6: Can psd delete the snapshots automatically?

A6: Yes, run psd with the "clean" switch to delete snapshots.

CONTRIBUTE
Users wishing to contribute to this code, should fork and send a pull request. Source is freely available on the project page linked below.

BUGS
Discover a bug? Please open an issue on the project page linked below.

    •   It is known that on slow systems with large profiles, the initial sync step can sometimes take longer than the boot-up of the WM. Therefore, users can theoretically start their browser before the profile has been transitioned to tmpfs. This is particularly prevalent on systems with slow HDDs running systemd. This effect can be exacerbated with excessively large profiles that store mail as well as browser profiles. Users can minimize this by using overlayfs mode described above. Minimizing the profile size can also help on these systems. See profile-cleaner for more on this: https://github.com/graysky2/profile-cleaner

    •   Currently, psd does not work with encrypted home directories.

    •   Currently, psd checks for running browsers before it starts/stops by their name. If you are running a process that happens to contain that name, it will falsely refuse to start until that process is not running. For an example, see: https://github.com/graysky2/profile-sync-daemon/issues/85

ONLINE

•   Project page: https://github.com/graysky2/profile-sync-daemon

•   Wiki page: https://wiki.archlinux.org/index.php/Profile-sync-daemon

AUTHOR
graysky (graysky AT archlinux DOT us)