Difference between revisions of "Profile-sync-daemon"

From ArchWiki
Jump to: navigation, search
(External Links Mentioning PSD)
(The "OnUnitActiveSec=" directive serves to clear the parameter before overriding it. Tested with systemd229 and invoking "systemctl --user list-timers" to check timer expiry.)
 
(116 intermediate revisions by 33 users not shown)
Line 1: Line 1:
[[Category:Web Browser]]
+
[[Category:Web browser]]
[[Category:Scripts]]
+
[[ja:Profile-sync-daemon]]
{{Article summary start}}
+
[[ru:Profile-sync-daemon]]
{{Article summary text|{{AUR|Profile-sync-daemon}} (psd) is a diminutive pseudo-daemon designed to manage your browser's profile in tmpfs and to periodically sync it back to your physical disc (HDD/SSD).  This is accomplished via a symlinking step and an innovative use of rsync to maintain back-up and synchronization between the two.  One of the major design goals of psd is a completely transparent user experience.}}
+
{{Related articles start}}
{{Article summary heading|Related}}
+
{{Related|Anything-sync-daemon}}
{{Article summary wiki|Anything-sync-daemon}}
+
{{Related|Firefox}}
{{Article summary wiki|Firefox}}
+
{{Related|Chromium}}
{{Article summary wiki|Chromium}}
+
{{Related|Opera}}
{{Article summary wiki|Opera}}
+
{{Related|Pdnsd}}
{{Article summary wiki|SSD}}
+
{{Related|SSD}}
{{Article summary end}}
+
{{Related articles end}}
  
== Benefits of Psd ==
+
{{AUR|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.
Running this daemon is beneficial for two reasons:
+
#Reduced wear to physical discs
+
#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 RAM, thus reducing wear to the physical disc and also greatly improving browser speed and 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.
+
== Design goals and benefits of psd ==
  
{{Note|Chromium actually keeps its cache directory '''separately''' from its browser profile directory.  It is not within the scope of profile-sync-daemon to modify this behavior; users are encouraged to refer to the [[Chromium_Tips_and_Tweaks#Cache_in_tmpfs]] section of the main [[Chromium_Tips_and_Tweaks]] article for several work-arounds.}}
+
#Transparent user experience
 +
#Reduced wear to physical drives
 +
#Speed
  
==Supported Browsers ==
+
Since the profile(s), browser cache*, etc. are relocated into [[tmpfs]] (RAM disk), the corresponding I/O associated with using the browser is also redirected from the physical drive to RAM, thus reducing wear to the physical drive and also greatly improving browser speed and responsiveness.
Currently, the following browsers are auto-detected and managed:
+
*[[chromium]]
+
*{{AUR|conkeror}}
+
*[[firefox]] (all flavors including stable, beta, and aurora)
+
*[http://www.webupd8.org/2011/05/install-firefox-nightly-from-ubuntu-ppa.html firefox-trunk]
+
*{{AUR|google-chrome}}
+
*[https://bbs.archlinux.org/viewtopic.php?id=117157 heftig's version of aurora]
+
*[[midori]]
+
*[[opera]]
+
*{{AUR|opera-next}}
+
*[[qupzilla]]
+
  
{{Note|Heftig's version of Aurora is an Arch Linux only browser.}}
+
{{Note|Some browsers such as Chrome/Chromium, Firefox (since v21), Midori, and Rekonq actually keeps their cache directories '''separately''' from their profile directory. It is not within the scope of profile-sync-daemon to modify this behavior; users are encouraged to refer to the [[Chromium tweaks#Cache in tmpfs]] section for Chromium and to the [[Firefox on RAM]] article for several workarounds. An easy fix is to move the various browsers' cache directory from their default location (e.g. {{ic|/home/$USER/.cache/<browser>/<profile>/}}) to the corresponding profile directory, e.g. {{ic|/home/$USER/.mozilla/firefox/<profile>/cache}}, and then symlink the new cache folder back to its original location. This way, profile-sync-daemon will automatically take into account the cache folder too.}}
{{Note|Firefox-trunk is an Ubuntu-only only browser.}}
+
  
==Setup and Installation==
+
== Setup and installation ==
{{AUR|Profile-sync-daemon}} is available for download from the [[Arch User Repository|AUR]].  Build it and install like any other package.
+
[[Install]] the {{AUR|profile-sync-daemon}} package.
  
=== Edit /etc/psd.conf ===
+
=== Edit the config file ===
Edit the included {{ic|/etc/psd.conf}} defining which user(s) will have their profiles managed by psd.
+
Run psd the first time which will create {{ic|$XDG_CONFIG_HOME/psd/psd.conf}} (referred to hereafter as as the config file) which contains all settings.
  
Example:
+
{{Note|Any edits made to this file while psd is active will be applied only after psd has been restarted from the systemd user service.}}
# List users separated by spaces whose browser(s) profile(s) will get symlinked
+
# and sync'ed to tmpfs.
+
# Do NOT list a user twice!
+
USERS="facade happy"
+
  
{{Note|At least one user must be defined.}}
+
$ psd
 +
First time running psd so please edit /home/facade/.config/psd/psd.conf to your liking and run again.
  
Optionally uncomment the BROWSERS array and populate it with whichever browser(s) are to be sync'ed to tmpfs. If the BROWSERS array stays commented (default) then all supported browser profiles will be sync'ed if they exist.
+
* Optionally enable the use of overlayfs to improve sync speed and to use a smaller memory footprint. Do this in the USE_OVERLAYFS variable. The user will require sudo rights to {{ic|/usr/bin/psd-overlay-helper}} to use this option and the kernel must support overlayfs version 22 or higher. See the FAQ below for additional details.
 +
* Optionally define which browsers are to be managed in the BROWSERS array. If none are defined, the default is all detected browsers.
 +
* Optionally disable the use of crash-recovery snapshots (not recommended). Do this in the USE_BACKUPS variable.
  
Example:  Let's say that both Chromium and Midori are installed but only Chromium is to be sync'ed to tmpfs since the user keeps Midori as a backup browser and it is seldom used:
+
Example:  Let's say that Chromium, Opera and Midori are installed but only Chromium and Opera are to be sync'ed to tmpfs since the user keeps Midori as a backup browser and it is seldom used:
  
 
  # List browsers separated by spaces to include in the sync. Useful if you do not
 
  # List browsers separated by spaces to include in the sync. Useful if you do not
Line 58: Line 44:
 
  #
 
  #
 
  # Possible values:
 
  # Possible values:
  #   chromium
+
  # chromium
  #   conkeror.mozdev.org
+
  # chromium-dev
  #   firefox
+
conkeror.mozdev.org
  #   firefox-trunk
+
  # epiphany
  #   google-chrome
+
firefox
  #   heftig-aurora  
+
  # firefox-trunk
  #   midori
+
  # google-chrome
  #   opera
+
  # google-chrome-beta
  #   opera-next
+
#  google-chrome-unstable
  #   qupzilla
+
heftig-aurora
 +
  # icecat
 +
#  luakit
 +
midori
 +
  # opera
 +
  # opera-developer
 +
  # opera-beta
 +
qupzilla
 +
#  palemoon
 +
#  rekonq
 +
#  seamonkey
 +
#  vivaldi
 
  #
 
  #
 
  # If the following is commented out (default), then all available/supported  
 
  # If the following is commented out (default), then all available/supported  
  # browsers will be sync'ed
+
  # browsers will be sync'ed, separated by comma
  BROWSERS="chromium"
+
  BROWSERS="chromium opera"
  
== Using PSD ==
+
Beginning with version 5.54 of psd, native support for overlayfs is included.  Uncomment the '''USE_OVERLAYFS="yes"''' line to enable it rather than the default full copy to reduce the memory costs and to improve sync/unsync operations.
=== Preview Mode (Parse) ===
+
 
The 'parse' option can be called to show users exactly what psd will do based on the /etc/psd.conf entered. Call it like so:
+
{{Note|This feature requires a Linux kernel version of 3.18.0 or greater to work.}}
  $ profile-sync-daemon parse
+
 
  Profile-sync-daemon v5.08
+
== Supported browsers ==
 +
 
 +
Currently, the following browsers are auto-detected and managed:
 +
* [[Chromium]]
 +
* [[AUR|chromium-dev]]
 +
* {{AUR|conkeror-git}}
 +
* [[Epiphany]]
 +
* [[Firefox]] (all flavors including stable, beta, and aurora)
 +
* {{AUR|google-chrome}}
 +
* {{AUR|google-chrome-beta}}
 +
* {{AUR|google-chrome-dev}}
 +
* [https://bbs.archlinux.org/viewtopic.php?id=117157 heftig's version of Aurora]: An Arch Linux-only browser
 +
* {{AUR|icecat}}
 +
* [[Luakit]]
 +
* [[Midori]]
 +
* [[Opera]]
 +
* Qupzilla
 +
* {{Pkg|rekonq}}
 +
* {{Pkg|seamonkey}}
 +
* {{AUR|vivaldi}}
 +
 
 +
== Using psd ==
 +
 
 +
=== Preview (parse) mode ===
 +
 
 +
The 'parse' option can be called to show users exactly what ''psd'' will do/is doing based on {{ic|$XDG_CONFIG_HOME/psd/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 v6.03 on Arch Linux.
 
   
 
   
Psd will manage the following per /etc/psd.conf settings:
+
  Systemd service is currently active.
 +
  Systemd resync service is currently active.
 +
  Overlayfs v23 is currently active.
 
   
 
   
  browser/psname:  chromium/chromium
+
  Psd will manage the following per /home/facade/.config/psd/psd.conf settings:
owner/group:    facade/users
+
sync target:    /home/facade/.config/chromium
+
tmpfs dir:      /tmp/facade-chromium
+
profile size:   81M
+
 
   
 
   
browser/psname:  firefox/firefox
+
  browser/psname:  chromium/chromium
owner/group:    facade/users
+
  owner/group:    facade/100
sync target:    /mnt/data/docs/facade/mozilla/firefox/1Zp9V43q.banking
+
  sync target:    /home/facade/.config/chromium
tmpfs dir:      /tmp/facade-firefox-1Zp9V43q.banking
+
  tmpfs dir:      /run/user/1000/facade-chromium
profile size:    5.9M
+
  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
+
  browser/psname:  firefox/firefox
owner/group:    facade/users
+
  owner/group:    facade/100
sync target:    /mnt/data/docs/facade/mozilla/firefox/obg67zqQ.proxy
+
  sync target:    /mnt/data/docs/facade/mozilla/firefox/f8cv8bfu.default
tmpfs dir:      /tmp/facade-firefox-obg67zqQ.proxy
+
  tmpfs dir:      /run/user/1000/facade-firefox-f8cv8bfu.default
profile size:    17M
+
  profile size:    145M
 +
  overlayfs size:  13M
 +
  recovery dirs:  none
  
As shown in the output and as stated above, if no specific browser or subset of browsers are defined in the BROWSERS array, psd will sync ALL supported profiles that it finds for the given user(s).
+
As shown in the output and as stated above, if no specific browser or subset of browsers are defined in the BROWSERS array, ''psd'' will sync ALL supported profiles that it finds for the given user(s).
  
=== Running PSD to Manage Profiles ===
+
=== Clean mode ===
Do not call {{ic|/usr/bin/profile-sync-daemon}} to sync or to unsync directly.  Instead use the provided service file.  The initial synchronization will occur when the pseudo-daemon starts. Additionally, cron (if running) will call it to ''sync'' or update once per hour.  Finally, psd will sync back a final time when it is called to stop.
+
The clean mode will delete ALL recovery snapshots that have accumulated. Run this only if you are sure that you want to delete them.
  
The provided daemon file should be used to interact with psd ({{ic|/usr/lib/systemd/system/psd.service}}):
+
$ psd c
# systemctl [option] psd.service
+
 +
Profile-sync-daemon v6.03 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
  
Available options:
+
=== Start and stop psd ===
start  Turn on daemon; make symlinks and actively manage targets in tmpfs.
+
stop Turn off daemon; remove symlinks and rotate tmpfs data back to disc.
+
enable  Autostart daemon when system comes up.
+
disable  Remove daemon from the list of autostart daemons.
+
  
Enable psd to start/stop at boot/shutdown ''(highly recommended)'' using:
+
With the release of the version 6.x series of psd, the only init system that is officially supported is systemd. Psd ships with a systemd user service to start or stop it (psd.service). Additionally, a provided resync-timer will run an hourly resync from tmpfs back to the disk. The resync-timer is started automatically with psd.service so there is no need to attempt to start the timer.
# systemctl enable psd.service
+
  
=== Sync at More Frequent Intervals (Optional) ===
+
For users unfamiliar with systemd user mode, use the following commands to enable the psd service:
  
{{Note|This step is NOT required. '''Psd''' will update once per hour on its own thanks to /etc/cron.hourly/psd-update -- psd does NOT remain running in memory!}}
+
$ systemctl --user [option] psd.service
  
Users wishing to have syncs occur more frequently can simply add a line to the root crontab to call the ''sync'' function of psd like so:
+
Available options: start stop enable disable status
  
# crontab -e
+
===Supported distros===
 +
Since psd is just a bash script with a systemd service, it should run on any flavor of Linux running systemd. Around a dozen distros provide an official package or user-maintained option to install psd. One can also build psd from source. See the official website for available packages and installation instructions.
  
Example syncing all profiles being managed once every ten minutes:
+
=== Sync at more frequent intervals (optional) ===
  */10 * * * *    /usr/bin/profile-sync-daemon sync &> /dev/null
+
The package provided re-sync timer triggers once per hour. Users may optionally redefine this behavior simply by [[Systemd#Editing provided units|extending the systemd unit]]. The example below changes the timer to sync once every ten minutes:
  
== Caveats for Firefox and Heftig's Aurora ONLY ==
+
{{hc|~/.config/systemd/user/psd-resync.timer.d/frequency.conf|<nowiki>
The way psd keeps track of browser profiles and sync targets requires users to have a unique name as the ''last directory'' for all profiles in their respective $HOME/.mozilla/<browser>/profiles.ini files. Psd will check when it is called to run for this and refuse if this rule is not satisfied.  The following is an example of a BAD profile that will fail the the test.  Note that although each full path is unique, they both ''end'' in the same name!  Again, the user must modify the profiles.ini and the corresponding directory on the filesystem to correct this in order to use Psd.
+
--------------------------------------------------------
 +
[Unit]
 +
Description=Timer for Profile-sync-daemon
  
$ cat ~/.mozilla/firefox/profiles.ini
+
[Timer]
+
OnUnitActiveSec=
[General]
+
OnUnitActiveSec=10m
StartWithLastProfile=1
+
</nowiki>}}
+
[Profile0 for user facade]
+
Name=normal
+
IsRelative=0
+
Path=/mnt/data/docs/'''facade'''/mozilla/firefox/'''myprofile.abc'''
+
Default=1
+
+
[Profile1 for user happy]
+
Name=proxy
+
IsRelative=0
+
Path=/mnt/data/docs/'''happy'''/mozilla/firefox/'''myprofile.abc'''
+
  
== Support ==
+
See {{ic|man systemd.timer}} for additional options.
Post in the [https://bbs.archlinux.org/viewtopic.php?pid=1026974 discussion thread] with comments or concerns.
+
  
== PSD On Other Distros ==
+
== FAQ ==
Psd is a simple bash script and should therefore run on any Linux distro. Below is a list of distros known to package psd, and a link to download their respective packages. As noted above, these are unsupported by the author due to their own, unique init scripts:
+
=== What is overlayfs mode? ===
  
=== Chakra ===
+
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="yes" line in {{ic|$XDG_CONFIG_HOME/psd/psd.conf}} followed by a restart of the daemon.
http://chakra-linux.org/ccr/packages.php?ID=5007
+
  
=== Debian ===
+
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.
To add the PPA (personal package archive) to your Debian (tested on squeeze) system, and to install psd:
+
 
 +
Since version 6.05 of psd, users wanting to take advantage of this mode MUST have sudo rights (without password prompt) to {{ic|/usr/bin/psd-overlay-helper}} or global sudo rights. The following line in {{ic|/etc/sudoers}} will supply your user with these rights. Add it using {{ic|/usr/bin/visudo}} as root:
 +
 
 +
foo ALL=(ALL) NOPASSWD: /usr/bin/psd-overlay-helper
 +
 
 +
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 how much data is written to the profile, but in common use cases the overlayfs size will always be less than the profile size.
 +
 
 +
=== I need more memory to accommodate my profile/profiles in /run/user/xxxx. How can I allocate more? ===
 +
The  standard way of controlling the size of /run/user is the RuntimeDirectorySize directive in {{ic|/etc/systemd/logind.conf}} (see the man page for logind.conf for more). By default, 10% of physical memory is used but one can increase it safely. Remember that tmpfs only consumes what is actually used; the number specified here is just a maximum allowed.
 +
 
 +
=== Why do I have another browser profile directory "foo-back-ovfs" when I enable overlayfs? ===
 +
The way overlayfs works is to mount a read-only base copy (so-called lower dir) of the profile, and manage the new data on top of that. In order to avoid resyncing to the read-only file system, a copy is used instead. So using overlayfs is a trade off: faster initial sync times and less memory usage vs. disk space in the home dir.
 +
 
 +
=== My system crashed and did not sync back. What do I do? ===
 +
 
 +
Odds are the "last good" backup of your browser profiles is just fine still sitting happily on your filesystem. Upon restarting {{ic|psd}} (on a reboot for example), a check is performed 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.
 +
 
 +
{{Note|Users can disable the snapshot/backup feature entirely by uncommenting and setting the USE_BACKUPS variable to 'no' in {{ic|$XDG_CONFIG_HOME/psd/psd.conf}} if desired.}}
 +
 
 +
=== Where can I find this snapshot? ===
 +
 
 +
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, chromium will be {{ic|~/.config/chromium-backup-crashrecovery-20130912_153310}} -- of course, the date_time suffix will be different for you.
 +
 
 +
=== How can I restore the snapshot? ===
 +
 
 +
* Stop {{ic|psd}}.
 +
* Confirm that there is no symlink to the tmpfs browser profile directory. If there is, ''psd'' did not stop correctly for other reasons.
 +
* Move the "bad" copy of the profile to a backup (do not blindly delete anything).
 +
* Copy the snapshot directory to the name that browser expects.
 +
 
 +
Example using Chromium:
 +
mv ~/.config/chromium ~/.config/chromium-bad
 +
cp -a ~/.config/chromium-backup-crashrecovery-20130912_153310 ~/.config/chromium
 +
 
 +
At this point you can launch chromium which will use the backup snapshot you just copied into place. If all is well, close the browser and restart psd. You may safely delete {{ic|~/.config/chromium-backup-crashrecovery-20130912_153310}} at this point.
 +
 
 +
=== Can psd delete the snapshots automatically? ===
 +
Yes, run psd with the "clean" switch to delete snapshots.
 +
 
 +
== Support ==
 +
 
 +
Post in the [https://bbs.archlinux.org/viewtopic.php?pid=1026974 discussion thread] with comments or concerns.
  
# echo "deb http://ppa.launchpad.net/graysky/utils/ubuntu quantal main" > /etc/apt/sources.list.d/graysky.list
+
== psd on other distros ==
# echo "deb-src http://ppa.launchpad.net/graysky/utils/ubuntu quantal main" >> /etc/apt/sources.list.d/graysky.list
+
# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys FF7F9516
+
# apt-get update
+
# apt-get install profile-sync-daemon
+
  
=== Gentoo ===
+
''psd'' is a bash script and should therefore run on any Linux distro.  Around a dozen distros provide an official package or user-maintained option to install psd.  See the [https://github.com/graysky2/profile-sync-daemon#installation-from-distro-packages official website] for available packages and installation instructions.
http://packages.gentoo.org/package/www-misc/profile-sync-daemon
+
=== Ubuntu ===
+
To add the PPA (personal package archive) to your Ubuntu (packages available for Lucid and newer) system, and to install psd:
+
  
$ sudo add-apt-repository ppa:graysky/utils
+
== See also ==
$ sudo apt-get update
+
$ sudo apt-get install profile-sync-daemon
+
  
== External Links Mentioning PSD ==
+
* http://www.webupd8.org/2013/02/keep-your-browser-profiles-in-tmpfs-ram.html
*http://www.webupd8.org/2013/02/keep-your-browser-profiles-in-tmpfs-ram.html
+
* http://bernaerts.dyndns.org/linux/250-ubuntu-tweaks-ssd
*http://bernaerts.dyndns.org/linux/250-ubuntu-tweaks-ssd
+

Latest revision as of 20:46, 26 March 2016

Profile-sync-daemonAUR (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 and benefits of psd

  1. Transparent user experience
  2. Reduced wear to physical drives
  3. Speed

Since the profile(s), browser cache*, etc. are relocated into tmpfs (RAM disk), the corresponding I/O associated with using the browser is also redirected from the physical drive to RAM, thus reducing wear to the physical drive and also greatly improving browser speed and responsiveness.

Note: Some browsers such as Chrome/Chromium, Firefox (since v21), Midori, and Rekonq actually keeps their cache directories separately from their profile directory. It is not within the scope of profile-sync-daemon to modify this behavior; users are encouraged to refer to the Chromium tweaks#Cache in tmpfs section for Chromium and to the Firefox on RAM article for several workarounds. An easy fix is to move the various browsers' cache directory from their default location (e.g. /home/$USER/.cache/<browser>/<profile>/) to the corresponding profile directory, e.g. /home/$USER/.mozilla/firefox/<profile>/cache, and then symlink the new cache folder back to its original location. This way, profile-sync-daemon will automatically take into account the cache folder too.

Setup and installation

Install the profile-sync-daemonAUR package.

Edit the config file

Run psd the first time which will create $XDG_CONFIG_HOME/psd/psd.conf (referred to hereafter as as the config file) which contains all settings.

Note: Any edits made to this file while psd is active will be applied only after psd has been restarted from the systemd user service.
$ psd
First time running psd so please edit /home/facade/.config/psd/psd.conf to your liking and run again.
  • Optionally enable the use of overlayfs to improve sync speed and to use a smaller memory footprint. Do this in the USE_OVERLAYFS variable. The user will require sudo rights to /usr/bin/psd-overlay-helper to use this option and the kernel must support overlayfs version 22 or higher. See the FAQ below for additional details.
  • Optionally define which browsers are to be managed in the BROWSERS array. If none are defined, the default is all detected browsers.
  • Optionally disable the use of crash-recovery snapshots (not recommended). Do this in the USE_BACKUPS variable.

Example: Let's say that Chromium, Opera and Midori are installed but only Chromium and Opera are to be sync'ed to tmpfs since the user keeps Midori as a backup browser and it is seldom used:

# List browsers separated by spaces to include in the sync. Useful if you do not
# wish to have all possible browser profiles sync'ed.
#
# Possible values:
#  chromium
#  chromium-dev
#  conkeror.mozdev.org
#  epiphany
#  firefox
#  firefox-trunk
#  google-chrome
#  google-chrome-beta
#  google-chrome-unstable
#  heftig-aurora
#  icecat
#  luakit
#  midori
#  opera
#  opera-developer
#  opera-beta
#  qupzilla
#  palemoon
#  rekonq
#  seamonkey
#  vivaldi
#
# If the following is commented out (default), then all available/supported 
# browsers will be sync'ed, separated by comma
BROWSERS="chromium opera"

Beginning with version 5.54 of psd, native support for overlayfs is included. Uncomment the USE_OVERLAYFS="yes" line to enable it rather than the default full copy to reduce the memory costs and to improve sync/unsync operations.

Note: This feature requires a Linux kernel version of 3.18.0 or greater to work.

Supported browsers

Currently, the following browsers are auto-detected and managed:

Using psd

Preview (parse) mode

The 'parse' option can be called to show users exactly what psd will do/is doing based on $XDG_CONFIG_HOME/psd/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 v6.03 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 /home/facade/.config/psd/psd.conf settings:

 browser/psname:  chromium/chromium
 owner/group:     facade/100
 sync target:     /home/facade/.config/chromium
 tmpfs dir:       /run/user/1000/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:     facade/100
 sync target:     /mnt/data/docs/facade/mozilla/firefox/f8cv8bfu.default
 tmpfs dir:       /run/user/1000/facade-firefox-f8cv8bfu.default
 profile size:    145M
 overlayfs size:  13M
 recovery dirs:   none

As shown in the output and as stated above, if no specific browser or subset of browsers are defined in the BROWSERS array, psd will sync ALL supported profiles that it finds for the given user(s).

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 v6.03 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

With the release of the version 6.x series of psd, the only init system that is officially supported is systemd. Psd ships with a systemd user service to start or stop it (psd.service). Additionally, a provided resync-timer will run an hourly resync from tmpfs back to the disk. The resync-timer is started automatically with psd.service so there is no need to attempt to start the timer.

For users unfamiliar with systemd user mode, use the following commands to enable the psd service:

$ systemctl --user [option] psd.service

Available options: start stop enable disable status

Supported distros

Since psd is just a bash script with a systemd service, it should run on any flavor of Linux running systemd. Around a dozen distros provide an official package or user-maintained option to install psd. One can also build psd from source. See the official website for available packages and installation instructions.

Sync at more frequent intervals (optional)

The package provided re-sync timer triggers once per hour. Users may optionally redefine this behavior simply by extending the systemd unit. The example below changes the timer to sync once every ten minutes:

~/.config/systemd/user/psd-resync.timer.d/frequency.conf
--------------------------------------------------------
[Unit]
Description=Timer for Profile-sync-daemon

[Timer]
OnUnitActiveSec=
OnUnitActiveSec=10m

See man systemd.timer for additional options.

FAQ

What is overlayfs mode?

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="yes" line in $XDG_CONFIG_HOME/psd/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.

Since version 6.05 of psd, users wanting to take advantage of this mode MUST have sudo rights (without password prompt) to /usr/bin/psd-overlay-helper or global sudo rights. The following line in /etc/sudoers will supply your user with these rights. Add it using /usr/bin/visudo as root:

foo ALL=(ALL) NOPASSWD: /usr/bin/psd-overlay-helper

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 how much data is written to the profile, but in common use cases the overlayfs size will always be less than the profile size.

I need more memory to accommodate my profile/profiles in /run/user/xxxx. How can I allocate more?

The standard way of controlling the size of /run/user is the RuntimeDirectorySize directive in /etc/systemd/logind.conf (see the man page for logind.conf for more). By default, 10% of physical memory is used but one can increase it safely. Remember that tmpfs only consumes what is actually used; the number specified here is just a maximum allowed.

Why do I have another browser profile directory "foo-back-ovfs" when I enable overlayfs?

The way overlayfs works is to mount a read-only base copy (so-called lower dir) of the profile, and manage the new data on top of that. In order to avoid resyncing to the read-only file system, a copy is used instead. So using overlayfs is a trade off: faster initial sync times and less memory usage vs. disk space in the home dir.

My system crashed and did not sync back. What do I do?

Odds are the "last good" backup of your browser profiles is just fine still sitting happily on your filesystem. Upon restarting psd (on a reboot for example), a check is performed 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.

Note: Users can disable the snapshot/backup feature entirely by uncommenting and setting the USE_BACKUPS variable to 'no' in $XDG_CONFIG_HOME/psd/psd.conf if desired.

Where can I find this snapshot?

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, chromium will be ~/.config/chromium-backup-crashrecovery-20130912_153310 -- of course, the date_time suffix will be different for you.

How can I restore the snapshot?

  • Stop psd.
  • Confirm that there is no symlink to the tmpfs browser profile directory. If there is, psd did not stop correctly for other reasons.
  • Move the "bad" copy of the profile to a backup (do not blindly delete anything).
  • Copy the snapshot directory to the name that browser expects.

Example using Chromium:

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

At this point you can launch chromium which will use the backup snapshot you just copied into place. If all is well, close the browser and restart psd. You may safely delete ~/.config/chromium-backup-crashrecovery-20130912_153310 at this point.

Can psd delete the snapshots automatically?

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

Support

Post in the discussion thread with comments or concerns.

psd on other distros

psd is a bash script and should therefore run on any Linux distro. Around a dozen distros provide an official package or user-maintained option to install psd. See the official website for available packages and installation instructions.

See also