Howto pause pm-suspend when program is running

I have a backintime running every hour. Sometimes, it’s running when I suspend/hibernate the machine. The suspend will fail, because backintime refuses to suspend. BIT will fail because network is pulled down. Then we have backintime running forever, and suspend/hibernate failing forever too(until you kill BIT manually).

This script will wait until backintime is done, and then let the computer suspend/hibernate.


case "${1}" in
    while pgrep -f "/usr/bin/backintime "; do
      sleep 5

exit 0

Remember to make the file executable.

Automated encrypted backup with Back In Time

Install encfs and zenity:

apt-get install encfs zenity

Create encrypted directory:

cd /whole/path/to
mkdir .backintime_encfs
mkdir backintime
encfs /whole/path/to/.backintime_encfs /whole/path/to/backintime

If you would like support for hard links(backintime incremental backups), choose the standard mode, not paranoia mode.

Script to mount and run backup:

# Script to mount encrypted directory and run backup.
extpass="zenity --title 'Encrypted backup' --entry 
--text 'Please type password for encrypted backup storage' --hide-text"

#set display for password prompt
export DISPLAY=:0.0
#check if directories exists
if [ -d $enc_path/$enc_directory ] && [ -d $enc_path/$directory ]
  # check if encrypted directory already is mounted
  mountpoint $enc_path/$directory > /dev/null
  if [ "$?" != "0" ]; then
    encfs --extpass="$extpass" $enc_path/$enc_directory $enc_path/$directory
  # check if mount was successful
  mountpoint $enc_path/$directory > /dev/null
  if [ "$?" = "0" ]; then
     echo "Running backup..."
     nice -n 19 /usr/bin/backintime --backup-job >/dev/null 2>&1
     # optional umount of encrypted storage:
     # fusermount -u $enc_path/$directory
     exit 0
    echo "Unable to mount encrypted directory"
    exit 1
  echo "Encrypted directory not found"
  exit 1

Disable schedule in Back In Time, and add script to crontab:

crontab -e
# add this line and save
@hourly /usr/local/bin/encrypted_backup_script


NFS4, hard links and backintime

After a kernel update, I noticed my backups in backintime took very long time. The backups also didn’t increment, every single backup used the same space -> several GB. Incremental backups should only take some MB, the amount of data that have been changed.

First I thought this was a bug in BIT, then zfs-fuse, but the error was in NFS4. When logged in to the server, I could create hard links. NFS4 could not do hard links. If I changed mount options to NFS3, hard links worked. But I don’t want to use NFS3 since NFS4 got username/id linking, so you don’t need the same userids on all of your systems. Seems like this is also why hard links didn’t work. Not sure if the error is because the new kernel does not enable idmapd by default, or if /etc/default/nfs-common was changed in the update. Anyhow, be sure that NEED_IDMAPD equals to yes in /etc/default/nfs-common on both server and clients.