Allow remote sources in config #99

Closed
opened 2018-10-06 12:29:54 +00:00 by christianhauff · 6 comments

Is there a reason why borgmatic allows remote borg repositorys as a destination but no remote folders as a source? I would like to use borgmatic on my backup server to "pull" files from one or several other servers, and borg itself should support this situation.

Am I doing anything wrong with having either user@example.com:/path/to/folder or ssh://user@example.com:/path/to/folder? I always get [Errno 2] No such file or directory

Is there a reason why borgmatic allows remote borg repositorys as a destination but no remote folders as a source? I would like to use borgmatic on my backup server to "pull" files from one or several other servers, and borg itself should support this situation. Am I doing anything wrong with having either `user@example.com:/path/to/folder` or `ssh://user@example.com:/path/to/folder`? I always get `[Errno 2] No such file or directory`
witten added the
question / support
label 2018-10-06 19:59:14 +00:00
Owner

Thanks for the question.. A remote "pull"-based source isn't something I've tried before. I'll give it a shot and see if I can reproduce locally.

Thanks for the question.. A remote "pull"-based source isn't something I've tried before. I'll give it a shot and see if I can reproduce locally.
Owner

Based on the Borg documentation, it doesn't look like using remote sources is supported directly/automatically. Instead, the docs suggest to use an sshfs mount to mount the remote host as if it were a local path. At that point, you can invoke borg create as per usual on a local path:

# Backup a remote host locally ("pull" style) using sshfs
$ mkdir sshfs-mount
$ sshfs root@example.com:/ sshfs-mount
$ cd sshfs-mount
$ borg create /path/to/repo::example.com-root-{now:%Y-%m-%d} .
$ cd ..
$ fusermount -u sshfs-mount

So if you wanted to do this with borgmatic, my recommendation would be to make use of the hooks feature. Basically, you would create the sshfs mount in a before_backup hook, and then unmount in the after_backup hook.

Something like (totally untested):

hooks:
    before_backup:
        - mkdir -p /local/path/sshfs-mount
        - sshfs user@example.com:/path/to/folder /local/path/sshfs-mount
    after_backup:
        - fusermount -u /local/path/sshfs-mount

Let me know if that works for your use case.

Based on the [Borg documentation](https://borgbackup.readthedocs.io/en/stable/usage/create.html#examples), it doesn't look like using remote sources is supported directly/automatically. Instead, the docs suggest to use an sshfs mount to mount the remote host as if it were a local path. At that point, you can invoke `borg create` as per usual on a local path: ``` # Backup a remote host locally ("pull" style) using sshfs $ mkdir sshfs-mount $ sshfs root@example.com:/ sshfs-mount $ cd sshfs-mount $ borg create /path/to/repo::example.com-root-{now:%Y-%m-%d} . $ cd .. $ fusermount -u sshfs-mount ``` So if you wanted to do this with borgmatic, my recommendation would be to make use of the [hooks feature](https://torsion.org/borgmatic/#hooks). Basically, you would create the sshfs mount in a `before_backup` hook, and then unmount in the `after_backup` hook. Something like (totally untested): ``` hooks: before_backup: - mkdir -p /local/path/sshfs-mount - sshfs user@example.com:/path/to/folder /local/path/sshfs-mount after_backup: - fusermount -u /local/path/sshfs-mount ``` Let me know if that works for your use case.
Author

Thanks for your answer! Then I didn't get that correct from the borg documentation, but I already thought of using sshfs as an alternative, your proposal sounds like a good possibility!

Thanks for your answer! Then I didn't get that correct from the borg documentation, but I already thought of using sshfs as an alternative, your proposal sounds like a good possibility!
Owner

Cool. Feel free to follow up here and let me know how it works out.

Cool. Feel free to follow up here and let me know how it works out.
Author

Just for documentation, what I've been doing now, if storage space is not an issue, is copying the remote location to a local folder using rsync, which is very fast detecting and copying only the changes, and backing-up that local folder. Even file dates, etc. can be preserved using the rsync -a option.

Just for documentation, what I've been doing now, if storage space is not an issue, is copying the remote location to a local folder using rsync, which is very fast detecting and copying only the changes, and backing-up that local folder. Even file dates, etc. can be preserved using the `rsync -a` option.
Owner

Okay, that sounds like it'll work. Note that you could also do that with borgmatic hooks if you so desired.

Okay, that sounds like it'll work. Note that you could also do that with borgmatic hooks if you so desired.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#99
No description provided.