Scheduled Backup over SSH directory creation fails

I have created a scheduled backup to upload over SSH. I have the following string as the destination file: /backup/%Y-%m-%d

However, even though "Create destination directory" is checked, it still fails:

Uploading archive to SSH server .. .. upload failed! Password: scp: /backup/2009-10-23: No such file or directory

These exact settings, when set to backup to the same location and username/password over regular FTP instead, works without a problem.

I have verified this is not a server-side issue by manually logging in with Filezilla over SFTP and being able to create the directory manually.

Status: 
Closed (fixed)

Comments

Which backup file format did you select? If you are backing up to a directory, make sure you select "One file per domain".

Also, did that /backup/YYYY-mm-dd directory actually get created on the server?

I selected "One file per server", and the directory does NOT get created when "SSH server" is selected, but does get created if "FTP server" is selected. No other settings at all change between the two except for FTP or SSH.

Does the remote SSH user perhaps have his shell set to scponly, or something that would prevent Virtualmin from SSHing in and running mkdir ?

No, I can SSH in using regular putty without an issue:

login as: [replaced username]

Using keyboard-interactive authentication.

Password:

Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994

    The Regents of the University of California.  All rights reserved.

FreeBSD 7.1-RELEASE-p2 (BACKUP16) #0: Sat May 30 21:36:24 UTC 2009

$ echo $SHELL

/bin/sh

$ mkdir testdir

$ ls

backup keys testdir

$ rm -r testdir

$ ls

backup keys

$

By the way, that backup dir there is due to me setting it to regular FTP only for now until we get this sorted out =)

Ok .. so if you backup via SSH to a fixed directory (not using data substitutions), does it create the directory successfully?

Unfortunately not. The error shown is:

Uploading archive to SSH server .. .. upload failed! Password: scp: /backup: Permission denied

Here are my settings:

http://dl.getdropbox.com/u/170406/pics/puttysettings.jpg

http://dl.getdropbox.com/u/170406/pics/settings.jpg

It did create the backup directory this time (no idea why), however no files were uploaded to it:

$ ls

backup keys

$

$ cd backup

$ ls

$

The permissions for the folder "backup" are correct:

$ ls -l

total 4

drwxr-xr-x 2 user user 512 Oct 26 04:31 backup

drwx------ 2 user user 512 Oct 23 23:44 keys

$

That's really odd .. if you run the backup again when the /backup directory exists, does it still fail?

Yes, it still fails with the same error:

Creating backup for virtual server example.com ..

Copying virtual server configuration ..
.. done

Backing up Cron jobs ..
.. none defined.

Saving mail aliases ..
.. done

Saving mail and FTP users ..
.. done

Backing up mail and FTP user Cron jobs ..
.. none to backup

Copying records in DNS domain ..
.. done

Copying Apache virtual host configuration ..
.. done

Copying Apache log files ..
.. done

Copying Webalizer configuration files ..
.. done

Copying Logrotate configuration ..
.. done

Dumping MySQL database example ..
.. done

Dumping MySQL database example_i958ga ..
.. done

Copying Procmail and SpamAssassin configuration files ..
.. done

Backing up Webmin ACL files ..
.. done

Backing up DAV users file ..
.. done

Backing up AWstats configuration file ..
.. done

Creating backup of Mailman mailing lists ..
.. no lists found

Creating TAR file of home directory ..
.. done

Uploading archive to SSH server ..
.. upload failed! Password:

scp: /backup: Permission denied Killed by signal 1.

Wait .. that "permission denied" error means that the SSH password was incorrect. Check the password field on the backup form..

I guarantee you that password is correct. The password is very simple to type.

Just to double check, I typed it into notepad, copied it into putty to login with it, and then copied it into the Virtualmin password field and the backup still failed. The username is correct as well.

Uploading archive to SSH server .. .. upload failed! Password: scp: /backup: Permission denied

Just to make sure this wasn't some sort of SCP server weirdness, I downloaded WinSCP and connected using the SCP protocol, and was able to create a directory using WinSCP without a problem.

Are you sure that the password form is passing the password I type in to the server correctly?

Does the password perhaps contain any odd characters like : or @ ?

Also, if you have access to the logs on the SSH server, what gets logged to /var/log/messages and /var/log/secure or /var/log/auth.log when you try to backup?

Hello,

The password does not contain any odd characters, it is only letters and numbers. Unfortunately I do not have access to the logs on the backup server as it is just a standard backup account purchased from serverorigin.

I am trying to get a copy of the exact error that is being logged on the server from ServerOrigin. I will try to get that to you as soon as they provide it.

Ok, thanks..

So does ServerOrigin offer some kind of SSH backup service?

Hello,

Yes, they offer (fairly cheap!) backup space over FTP and SCP/SFTP (http://www.serverorigin.com/backup.php). This is their response:

Russell, Sadly, SSH logs are not very detailed. Can you provide the full error you are receiving? We can help track it further on our end as well.

Thanks

I have provided them all of the information I gave you (as well as let them know that you are involved in troubleshooting so that perhaps they take it more seriously). I really don't understand. I am willing to change my password on serverorigin to a temporary one and see if maybe you can establish a connection on your end with your own copy of Virtualmin if you would like. That would at least let us know if the problem is a "global" issue with perhaps ServerOrigin's setup or Virtualmin itself, or if its just an issue with my individual installation.

Sure, if I could try a test backup to the same destination you are using, that would be very useful. It may be that there is something different in the way their SSH server works which confuses Virtualmin, as I've only tested it against regular Linux systems.

You could email me a test login and password at jcameron@virtualmin.com

Got it figured out!

Looks like the problem was the / in front of the backup directory. FTP jails you to your home directory, so as far as the FTP server is concerned /backup really is /backup. However with SSH, it doesn't jail you in your home directory so when it was attempting to upload to /backup, it was trying to upload literally to the path /backup.

Taking the / out from in front of it fixed the situation!

Doh!

Ah .. that would explain it! Alternatively, you could have entered /home/whatever/backup as the directory.

Yep... but I'm still having weirdness.

Unfortunately it is uploading now, but isn't actually uploading into a directory. It makes the "backup" directory and then for some reason uploads everything into a giant file called 2009-10-28 instead of making the folder and uploading the individual .tar.gz's like normal! Like before, FTP works fine, its just SSH having problems.

I have tried adding a trailing / at the end, but Virtualmin strips that last / off when I click save. I have also tried backup/%Y-%m-%d as the path and /usr/home/username/backup/%Y-%m-%d to no avail, both create a big file instead of a directory.

The only way it uploads correctly, is if I disable the date substitutions, IE, only upload into a folder called "backup".

Did you select "One file per domain" as the backup format?

Also, you should enter the full path like /usr/home/username/backup/%Y-%m-%d ..

Yes, it's at one file per server, and the full path is in there. It still drops it as a single large unreadable file with the name of the file as the date. Very strange.

I have emailed you login information for both the Virtualmin server and the backup account. I cleaned out the backup account so its completely clean.

Thanks for the login .. I am checking it out now.

Ok, I just tried a couple of backups .. and they seemed to work fine. The destination directory was created, and the expected files put into it.

This was done from within Virtualmin, at Scheduled Backups -> Backup..

I don't understand how yours is working but mine isn't.

I went to scheduled backups - backup - backup now. Here are the results:

Putty window:

$ ls

keys

[The Virtualmin backup finished]

$ ls

backup keys

$ cd backup

$ ls

2009-10-29

$ cd 2009-10-29

cd: can't cd to 2009-10-29

$

Virtualmin window:

Starting backup of 1 domains to /usr/home/user/backup/2009-10-29 on SSH server backup.serverorigin.com ..

Creating backup for virtual server example.com ..

  Copying virtual server configuration ..
  .. done

  Backing up Cron jobs ..
  .. none defined.

  Saving mail aliases ..
  .. done

  Saving mail and FTP users ..
  .. done

  Backing up mail and FTP user Cron jobs ..
  .. none to backup

  Copying records in DNS domain ..
  .. done

  Copying Apache virtual host configuration ..
  .. done

  Copying Apache log files ..
  .. done

  Copying Webalizer configuration files ..
  .. done

  Copying Logrotate configuration ..
  .. done

  Dumping MySQL database example ..
  .. done

  Dumping MySQL database example_db ..
  .. done

  Copying Procmail and SpamAssassin configuration files ..
  .. done

  Backing up Webmin ACL files ..
  .. done

  Backing up DAV users file ..
  .. done

  Backing up AWstats configuration file ..
  .. done

  Creating backup of Mailman mailing lists ..
  .. no lists found

  Creating TAR file of home directory ..
  .. done

  Uploading archive to SSH server ..
  .. done

Backing up Virtualmin settings (Module configuration, Server templates, New mailbox email messages, Custom fields, links and shells, Scheduled Virtualmin backups, FTP directory restrictions) .. .. done

Uploading archive to SSH server .. .. done

1 servers backed up successfully, 0 had errors. 6 Virtualmin configuration settings backed up successfully.

Backup is complete. Final size was 6.43 MB.

I don't understand. I tried both "Backup Now" and "Backup in background". Both supposedly completely correctly but I cannot cd into that directory.

What did you do differently?

Ah...... I got it....

I assumed that since "make destination directory" was checked, it would make all of the directories that were missing. Once I manually made the "backup" directory, the "date" directory is being made correctly now. That's what was causing the weirdness, it would make the backup directory but not the final destination directory.

Woops again. Leave it to someone to find a way to break it eh?

Thanks for your help, you've been very patient!

Ok, that would explain it .. if the parent dir doesn't exist, odd things could happen.

Sadly there is no reliable way to create directories recursively via scp :-(

Automatically closed -- issue fixed for 2 weeks with no activity.