From 23f1cb06d6b067e704d27cf1aa466ed0c5b27c84 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 30 Sep 2017 10:21:56 +0200 Subject: [PATCH 1/4] Fix FAQ --- doc/faq.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/faq.rst b/doc/faq.rst index 80dbc186f..9d6502b46 100644 --- a/doc/faq.rst +++ b/doc/faq.rst @@ -33,9 +33,9 @@ How can I specify encryption passwords automatically? When you run ``restic backup``, you need to enter the passphrase on the console. This is not very convenient for automated backups, so you can also provide the password through the ``--password-file`` option, or one of -the environment variables ``RESTIC_PASSWORD`` or ``RESTIC_PASSWORD_FILE`` -environment variables. A discussion is in progress over implementing unattended -backups happens in :issue:`533`. +the environment variables ``RESTIC_PASSWORD`` or ``RESTIC_PASSWORD_FILE``. +A discussion is in progress over implementing unattended backups happens in +:issue:`533`. .. important:: Be careful how you set the environment; using the env command, a `system()` call or using inline shell From 89c2ed2a1c5d23f19c7c6874659ed3f7ff71a818 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 30 Sep 2017 10:24:28 +0200 Subject: [PATCH 2/4] manual: Document that sftp does not expand tilde --- doc/manual.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/manual.rst b/doc/manual.rst index 011e71f36..b0beb8df3 100644 --- a/doc/manual.rst +++ b/doc/manual.rst @@ -146,6 +146,11 @@ You can also specify a relative (read: no slash (``/``) character at the beginning) directory, in this case the dir is relative to the remote user's home directory. +.. note:: Please be aware that sftp servers do not expand the tilde characte + (``~``) normally used as an alias for a user's home directory. If you + want to specify a path relative to the user's home directory, pass a + relative path to the sftp backend. + The backend config string does not allow specifying a port. If you need to contact an sftp server on a different port, you can create an entry in the ``ssh`` file, usually located in your user's home directory at From fae3c4d437c2109009ae29cc4ecb55f55408694b Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 30 Sep 2017 10:30:21 +0200 Subject: [PATCH 3/4] faq: Add entry about Synology NAS' sftp path --- doc/faq.rst | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/doc/faq.rst b/doc/faq.rst index 9d6502b46..55bc2311f 100644 --- a/doc/faq.rst +++ b/doc/faq.rst @@ -90,3 +90,28 @@ scheduling algorithm to give it the least favorable niceness (19). The above example makes sure that the system the backup runs on is not slowed down, which is particularly useful for servers. + +Creating new repo on a Synology NAS via sftp fails +-------------------------------------------------- + +Sometimes creating a new restic repository on a Synology NAS via sftp fails +with an error similar to the following: + +:: + + $ restic init -r sftp:user@nas:/volume1/restic-repo init + create backend at sftp:user@nas:/volume1/restic-repo/ failed: + mkdirAll(/volume1/restic-repo/index): unable to create directories: [...] + +Although you can log into the NAS via SSH and see that the directory structure +is there. + +The reason for this behavior is that apparently Synology NAS expose a different +directory structure via sftp, so the path that needs to be specified is +different than the directory structure on the device and maybe even as exposed +via other protocols. + +The following may work: + +:: + $ restic init -r sftp:user@nas:/restic-repo init From 556a63de198b14df6054f3663b8eeb1b4bcf4763 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 30 Sep 2017 10:34:23 +0200 Subject: [PATCH 4/4] sftp: Return error when path starts with a tilde (~) --- internal/backend/sftp/config.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/backend/sftp/config.go b/internal/backend/sftp/config.go index 708150206..90fe52c39 100644 --- a/internal/backend/sftp/config.go +++ b/internal/backend/sftp/config.go @@ -64,9 +64,15 @@ func ParseConfig(s string) (interface{}, error) { default: return nil, errors.New(`invalid format, does not start with "sftp:"`) } + + p := path.Clean(dir) + if strings.HasPrefix(p, "~") { + return nil, errors.Fatal("sftp path starts with the tilde (~) character, that fails for most sftp servers.\nUse a relative directory, most servers interpret this as relative to the user's home directory.") + } + return Config{ User: user, Host: host, - Path: path.Clean(dir), + Path: p, }, nil }