[release] sFTP backups for DirectAdmin (version: 0.1.poralix)

Have a look at line 110 in the ftp_upload.php file and change .gz to .zst
Code:
FROM
cat ${DUMP} | grep -v '^sftp> ' | grep -E '(.*)\.tar(|\.gz)(|\.enc)$';

TO
cat ${DUMP} | grep -v '^sftp> ' | grep -E '(.*)\.tar(|\.zst)(|\.enc)$';

That will allow you to restore an account using DA backup/restore option. However, changing the code will only display .zst files and not many existing .gz.
Hi , I don't have any problems, it was more a request for the author to change his code on the github
Personally I don't think this is the right approach, I have altered ftp_list.php like:
Code:
cat ${DUMP} | grep -v '^sftp> ' | grep -E '(.*)\.tar(|\.zst)(|.gz)(|\.enc)$';
I can see al my backup extensions old and new one Tested with backup and recover and it works fine
 
@Active8, my mistake I wrote ftp_upload.php in my reply and should have wrote ftp_list.php.

The approach used would depend entirely on whether you have older .gz backups or not. If you have both I would go with your approach.
 
Hi. Thanks for a great plugin. I've been using it for backing up a few servers over SSH with password authentication and it has been working great. I wanted to add SSH key authentication instead but having some issues and can't seem to get it to work.

What I've done is that I've added SSH keys generated on the DirectAdmin server to the remote backup server and disabled password login on the remote backup server. Key authentication works on the backup server and I can connect to it without problems with one of the keys (my local computer).

When trying to create a backup from the DirectAdmin server I have added the following settings:

Server IP: xxx.xxx.xxx.xxx
Username: root
Password: /root/.ssh/id_rsa.pub (which is the path to the public key) and I've also tried /root/.ssh/id_rsa
Port: 22

But when running the backup I get an error message saying:

Code:
sftp return code: 255
Could not create directory '/.ssh'.
Warning: Permanently added 'xxx.xxx.xxx.xxx' (ECDSA) to the list of known hosts.
[email protected]: Permission denied (publickey).
Connection closed.
Connection closed
FTP information invalid.

Is there anyone having an idea of why it's not working? Is there something I have missed? Could it be that DA can't read the key from the /root directory? Should I move the key somewhere else, and if so, where?

Thanks!
 
Last edited:
I have posted an issue here. It seems there is a problem with permissions for the Private key. On clicking the "Schedule" or "Modify" buttons, it seems that the user "nobody" needs access to the private key. However when the backup actually runs and needs to be uploaded, it is the user "diradmin" that requires access. The only thing that has worked for me so far, is swapping the permissions from one user to the other in between.
 
Hi , I don't have any problems, it was more a request for the author to change his code on the github
Personally I don't think this is the right approach, I have altered ftp_list.php like:
Code:
cat ${DUMP} | grep -v '^sftp> ' | grep -E '(.*)\.tar(|\.zst)(|.gz)(|\.enc)$';
I can see al my backup extensions old and new one Tested with backup and recover and it works fine

A little correction, it ends with tar.gz or tar.zst and not on tar.zst.gz!
Bash:
cat ${DUMP} | grep -v '^sftp> ' | grep -E '(.*)\.tar(|\.enc|\.gz|\.zst)$';
But thanks for your addition very useful.
 
I am just trying to deploy your script on my new panel and I get the following error code:
  • sftp return code: 5
    Could not create directory '/nonexistent/.ssh'.
    Warning: Permanently added '**My local ip**' (ECDSA) to the list of known hosts.
    Permission denied, please try again.
    FTP information invalid.

    Does anyone know why this happens and how to fix it?
    And (incase this is relevant) I also have deployed this on my other DA install without issue.
 
I am just trying to deploy your script on my new panel and I get the following error code:
  • sftp return code: 5
    Could not create directory '/nonexistent/.ssh'.
    Warning: Permanently added '**My local ip**' (ECDSA) to the list of known hosts.
    Permission denied, please try again.
    FTP information invalid.

    Does anyone know why this happens and how to fix it?
    And (incase this is relevant) I also have deployed this on my other DA install without issue.
Update:
For now it seems like it just decided to work. But i still have no clue why. So if anyone can shed some light, that would be apriciated.
 
Does anyone know how i can add an SSH Key?
I see the script can use it but i have no clue how to set it up.
 
  • sftp return code: 3
    Failed to change pseudo terminal's permission: Operation not permitted
    FTP information invalid.
Hi @jamesf, did you ever resolve this?

I think I've narrowed it down to a permission issue with the admin user. I can run the sshpass command manually from the terminal as root, but not as admin.

Thanks,
Michael
 
Hi. Thanks, great plugin.
I have just installed it and so far everything works as expected, thanks again.
 
Minor problem: list cannot see the newer tar.zst files on the remote server when trying to restore.
 
Do you run a server hosted at OVH with a custom OVH kernel?
Yes.

I ended up writing my own script to pull the backups to my offsite server. I have enough storage that I can let them run then pick them up 12 hours or so later.
 
Hi,

I am attempting to set this script up on my DirectAdmin server, I downloaded the files, installed sftp + sshpass.

When i have the following configuration in my Admin Backup.
firefox_nSbT2JpCNJ.png
I ensured to add my custom port to the 3 custom files in the scripts folder.
When i click save it saves successfully so the connection works fine, but once i attempt a backup the following error is thrown.
firefox_8yh5WnsR9o.png

I saw earlier in the thread someone had a similar issue and switching off Secure FTP worked for them, but that's not the case for me.
Any help would be appreciated
 
Thank you for the suggestions and your feedback, guys.

According to these articles:

- https://docs.directadmin.com/change...#optional-zstd-compression-for-backup-restore
- https://docs.directadmin.com/changelog/version-1.38.4.html

backup files in DirectAdmin might be named in the following formats depending on settings:

Without encryption:

  • zstd=1 & backup_gzip=2 & encryption=0 => admin.root.admin.tar.zst
  • zstd=0 & backup_gzip=1 & encryption=0 => admin.root.admin.tar.gz
  • zstd=0 & backup_gzip=0 & encryption=0 => admin.root.admin.tar
With encryption:

  • zstd=1 & backup_gzip=2 & encryption=1 => admin.root.admin.tar.zst.enc
  • zstd=0 & backup_gzip=1 & encryption=1 => admin.root.admin.tar.gz.enc
  • zstd=0 & backup_gzip=0 & encryption=1 => admin.root.admin.tar.enc

The updated version addresses all of them.

Will you try the updated version from here: https://github.com/poralix/directadmin-sftp-backups
 
I saw earlier in the thread someone had a similar issue and switching off Secure FTP worked for them, but that's not the case for me.
Any help would be appreciated


What will you get if you try as root the following command trying to connect to a remote SSH/SFTP server?

Code:
/usr/bin/sftp -oPort=PORT USERNAME@IP

Make sure to replace the following

- PORT - with a remote SSH port
- USERNAME - with a SSH username
- IP - with an IP of a remote host
 
What will you get if you try as root the following command trying to connect to a remote SSH/SFTP server?

Code:
/usr/bin/sftp -oPort=PORT USERNAME@IP

Make sure to replace the following

- PORT - with a remote SSH port
- USERNAME - with a SSH username
- IP - with an IP of a remote host

Hi @zEitEr,

Thanks for your reply. The screenshots of the output are below.

The SFTP command works successfully and can see the output folder, aswell as write to it.
MobaXterm_MhMjlfzkEs.png

chrome_PI2qcQSxk7.png

Thanks,

Felix
 
Back
Top