Skip to content
tadly edited this page Sep 15, 2018 · 17 revisions

Configuration

dups reads its config from ~/.config/dups/config.yaml.

To store backups on a local target, your config would look like:

target:
  path: /absolute/local/path/

To store backups on a remote target, your config would look like:

target:
  path: /absolute/remote/path/
  host: <backup-host>

To change ssh related options like user, port, key-file etc. the ssh config file is used.

For remote backups to work, you have to have ssh key-based authentication set up.
Passphrases are not supported.

Additional config options can be found here.

Managing items

Includes

List includes

To list all includes you use --li, --list-includes.

Add includes

To include files, folders and patterns you use -i, --include.

$ dups -i /absolute/path/to/file.txt
$ dups -i /absolute/path/to/folder

To include items based on patterns you have to use single quotes to prevent the shell from expanding it.

# Includes all .png files contained in "/absolute/path/to/folder"
$ dups -i '/absolute/path/to/folder/*.png'

# Includes all .png files contained in "Pictures" (subdirectories excluded)
# for all users
$ dups -i '/home/**/Pictures/*.png'

include patterns will ultimately rely on shell expansion.

Remove includes

To remove included items you use --ri, --remove-includes.

dups --ri /absolute/path/to/file.txt
dups --ri '/absolute/path/to/folder/*.png'

Excludes

List excludes

To list all excludes you use --le, --list-excludes.

Add excludes

To exclude files, folders and patterns you use -e, --exclude.

$ dups -e /absolute/path/to/file.txt
$ dups -e /absolute/path/to/folder

To exclude items based on patterns you have to use single quotes to prevent the shell from expanding it.
Unlike includes, excludes will not rely on shell expansion and are applied while generating the file list.
If a to-be-included item matches one of the patterns, it will be excluded.

# Excludes ALL .mkv files
$ dups -i '*.mkv'

# Exclude all .mkv files contained in "Videos" (subdirectories excluded) for
# all users.
$ dups -i '/home/**/Videos/*.mkv'

Remove excludes

To remove excluded items you use --re, --remove-excludes.

dups --re /absolute/path/to/file.txt
dups --re '*.mkv'

Managing backups

Create backups

To start a new backup you use backup or the alias b.

To have backups run in the background you first need a daemon.
Once a daemon is running, you can start a new background backup by adding --bg for user daemons or --sbg for system daemons.

$ dups backup
$ dups backup --bg

List backups

To list all backups you use -l, --list.

$ dups backup -l
Name             Date                    Valid
20180801180005   01, Aug 2018 18:00:05   yes
20180802180005   02, Aug 2018 18:00:05   yes
20180803180006   03, Aug 2018 18:00:06   yes
...

Restore backups

To restore a backup you use restore or the alias r.
This would restore the entire backup to its original location overwriting all existing files.

$ dups restore

To restore a specific backup you use -b, --backup and add the backups name.
The keyword latest will automatically resolve to the latest backup.

$ dups restore -b latest
$ dups restore -b 20180801180005

To restore the nth most recent backup you use -n, --nth.

# Restores from the most recent backup.
$ dups restore -n 0

# Restores from the 5th most recent backup.
$ dups restore -n 5

To restore only certain files to a specific target you first add the target followed by a list of items to restore.

# Restores the given files to their original location.
$ dups restore -b 20180801180005 / /path/to/file.txt /path/to/file2.txt

# Restores the given files including the directory hierarchy to /tmp instead.
$ dups restore -b 20180801180005 /tmp /path/to/file.txt /path/to/file2.txt

To have backups restore in the background you first need a daemon.
Once a daemon is running, you can start a new background restore by adding --bg for user daemons or --sbg for system daemons.

$ dups restore -b 20180801180005 --bg

Remove backups

To remove individual backups you use remove or the alias rm.

$ dups remove 20180801180005

To remove all backups but keep n of the most recent you add --all-but-keep.

$ dups remove --all-but-keep 7

To remove all backups older than some given time you add --older-than.
The value is a combination of amount and identifier and supports:

Identifier Unit
s Seconds
m Minutes
h Hours
d Days
w Weeks
# Removes all backups older than 7 Weeks
$ dups remove --older-than 7w

Log files

Both backup and restore logs are stored in ${HOME}/.cache/dups/.
To print the most recent log you use --log.

$ dups backup --log
$ dups restore --log

# Tip: To search within the log you can simply pipe the output to less or vi(m)
$ dups backup --log | less
$ dups restore --log | vim -

Daemon

dups can be run as a daemon to handle backup and restore tasks in the background.

To start a daemon you use either --daemon or --system-daemon.

User daemon

The user daemon (--daemon) is intended for user-sessions and should suffice for most cases.
To backup/restore items owned by other users (e.g. root) have a look at the system daemon.

System daemon

The system daemon (--system-daemon) is intended for users who need to include files owned by other users (e.g. root).

To still read the correct config files (for both dups and ssh) you add --user and your username.

# This has to be run as root
$ dups --system-daemon --user <your-username>

To still get desktop notifications, you have to additionally start a user daemon.

Systemd

If system files have been included in your installation, there are systemd services available for both, the user daemon and the system daemon.

User service

$ systemctl --user enable dups
$ systemctl --user start dups

System service

$ systemctl enable dups@<your-username>
$ systemctl start dups@<your-username>

Scheduled backups

Scheduling is not included in dups but instead relies on external tools like cron.

I recommend cronie for systems where it is available. If not available, anacron (which cronie is based upon) is your best bet.

Here is an example on how I schedule my backups.

0 18 * * * nm-online -q -t 180 && dups --yes rm --but-keep 13 && dups backup --system-background

This will:

  1. Use NetworkManager to wait up to 3 minutes for a network connection.
  2. Remove all, but keep the most recent 13 backups
  3. Instruct my system daemon to start a new backup (resulting in 14 backups total)

FAQ

I have not been asked questions yet :)