Backup single file


I want to backup a single file using restic. I know how to do this with folders and with the option --files-from.

Is there an option like restic -r /srv/restic-repo backup file.sql ?


Yes, it is possible to backup a single file like that. You’ll see the filepath+filename on the “Paths” section on snapshot listing.

Note that you can even use stdin as backup source, e.g.:

mysqldump -u <user> -p <password> <...> | restic -r <repo> backup --stdin --stdin-filename db_backup.sql

This is how I currently use it. However, it seems that sometimes it takes too long to connect to the restic repository on the backup server (Hetzner Storage Box) via SFTP and mysqldump aborts the backup.

To prevent this I would first create the MySQL dump and then backup the file to the backup server via restic.

Ah, I see. The command

mysqldump -u <user> -p <password> <...> | restic -r <repo> backup --stdin --stdin-filename db_backup.sql


mysqldump -u <user> -p <password> <...> > db_backup.sql
restic -r <repo> backup db_backup.sql

will result in identical repository changes (maybe except the saved metadata like permissions for that file).