Last modified: 2021-09-09 17:05

Remote Locations

GIO Mounts

af uses GVFS to connect to network source or destination locations. The gio is for destinations.

dir	/var/backups/pi/markdown
history	HISTORY
editor	+vi

omit	^(out\.)
omit	\.(html|tar\.gz|zip)$

[net]
gio	smb://username@net-pi/home
dir	network-storage/backups/markdown

defines two different archives. The first is the usual location on the same computer (for daily or even more often backups) but the second is on a network computer (for weekly or release backups). In this case it is the home share on the CIFS server net-pi but it could be any GVFS mount like sftp or webdav. See the gvfs(7) manpage for more information.

GVFS location must be mounted before they can be used:

af mount net:

selects the net configuration sections and mounts the configured gvfs address using gio mount, which may ask for login credentials. When you are finished you can unmount the GVFS disk using system commands or with af's unmount command:

af unmount net:

af changes its copy mode when using GVFS locations. Instead of preserving timestamps and permissions (and possibly the file's user and group) the constructed cp command have only --preserve=timestamps set because af cannot know what is supported by the remote end. For remote destinations permissions and owner are recorded in the .archive.tab file and can be restored from there by setting the -p option when running restore-files.

MTP devices

MTP devices are very much like GIO mounts and used the same was as the gio option but mtp for the archive's source side.

mtp gvfs-mount
dir location

declares the source directory to be located under the device's GVFS mount point. E.g.

dir     ~/my-phone

mtp     mtp://some-phone-identifier
src       Interner gemeinsamer Speicher/DCIM/Camera:camera
src       Interner gemeinsamer Speicher/Pictures:pictures
src       Interner gemeinsamer Speicher/Download:download

defines three directories to be archived on the local computer. mtp can be used to address not only MTP devices but arbitrary GVFS endpoints.

mtp    smb://net-pi/home
src    work

would configure the home-share on net-pi.

Since the mtp option refers to the source location it is not permitted in a configuration section. Furthermore, only the commands

are available if the remote source is not mounted.

Remote Logins

af can archive files from a remote server. MTP mounts deliver something similar. The differences are that you need (1) to have GVFS installed and (2) mount the remote location first. With remote logins af uses a combination of ssh and sftp (you need permissions for both on the remote end) and relies on the server's operation system installation, which must a have a modern GNU find. Furthermore, you need to have ssh key authentication enabled and the key must be already unlocked with ssh-add because sftp doesn't ask for a password (it is called in batch mode).

A suitable .archive-files.conf would be

dir     .

src     work
remote  pi@pi-server

and af would be used ust as for local files: af list prints the changed files, af show lists the commands (you might want to verify them before running) an af creates a backup volume. With

type	+backup -copy .backups

you would create a local mirror with an archive of older files in the .backups directory.

While the functionality is superseded by GIO mounts and expects GNU find I decided to keep it in the script because the required code is small. There is however one use case where remote logins are better the GIO mounts. This is when you have multiple remote system from which you want to backup files and have distributed the same ssh key on them. Then you need to only unlock that while you would need to mount each system individually vie GVFS.

Backing up a remote /etc directory

If you want to backup remote /etc directories the setup would be a little bit different. First you must login to the remote side as root

dir     .

src     /etc
remote  root@pi-server

to get the permissions to read almost all files in /etc. Second, you must install the ssh key in root's .ssh/authorized_keys file.

Third, to preserve the remote permission on the local backup files you need to invoke af as root. Run sudo -E af to keep access to your unlocked ssh key.