Hass.io Addon FTP-Backup

Hello everyone,

I’ve created my first addons and maybe someone else will be interested here.

The ftp-backup will create a password protected ZIP Archive of the home assistantconfiguration (/config) and stores the ZIP under /backup
Once it finished it will upload the ZIP Archive to the configured ftp server.

Feedback is welcome.

2 Likes

I think the syntax of the curl command to the FTP server is incorrect. It should be in the format: curl ftp://ftp.domain.com --user username:password

@slomanl1

I think both is valid:

curl ftp://name:[email protected]:port/fullpath
and
curl -u name:passwd ftp://machine.domain:port/fullpath

At least both are working the same for me.

Are you cafing any issue?
Please let me know.

The FTP syntax will not work on Windows based FTP servers. Refer to this article below:

Microsoft is disabling support in Internet Explorer for this kind of information inclusion in HTTP and HTTPS protocol URLs.
https://www.cs.rutgers.edu/~watrous/user-pass-url.html

Would be great if it could do sftp or copy over ssh :slight_smile:

2 Likes

@slomanl1
I uploaded a new version.

@oakbrad
I also added the option “ftpprotocol” and “addftpflags” which you could use to pass the needed parameters for sftp.

Feedback is welcome.

Looks really great!

I’m a new user, could you give an example of how the SFTP part works?

It really depends on your SFTP Server used.
A simple sftp example would look like following:
{
“ftpprotocol”: “sftp”,
“ftpserver”: “example.myserver.com”,
“ftpport”: 22,
“ftpbackupfolder”: “homeassistant”,
“ftpusername”: “ftpusername”,
“ftppassword”:“ftppassword”,
“addftpflags”: “”,
“zippassword”: “homeassistant”
}

1 Like

Thanks for the example.

I’ve tried setting it up, but is getting the following error:

[Info] trying to upload /backup/homeassistant_backup_20180201222104.zip to sftp://nas.mysite.com:22/test/
curl: (51) SSL peer certificate or SSH remote key was not OK

Trying to login on the SFTP user with filezilla works great. The SFTP server is running on a Synology NAS.

You may try to add
-k to addftpflags

1 Like

Works!

Thanks a lot. Your plugin is really great. It’s easy to install, easy to configure (With a little help :wink: ). Thanks for contributing to HomeAssistant!

What about scheduling? Is it manually, once a day or how does this work? Can’t seem to find anything about it in the doc.

Every time you start the addon it will perform a backup.

I just fixed an issue with the slug.
Seems that the “-” in the slug “ftp-backup” was causing issues.
With Version 0.2.4 you should now be able to use automations with the addon.
So you can trigger the addon whenever you like
image

What I will look into (if I find some spare time) is to perform only backup if there has been changes to the configuration meanwhile.

I really like the idea about checking for changes. But might be a little tricky to do.

Anyways, where do you get the “{“addon”:“c80014cb_ftpbackup”}” from? (Name of the addon?)

1 Like

After some research the repository ID is c80014cb and the slug I defined is ftpbackup
I got it via SSH and the commend “hassio supervisor info|more”.
You can also get the slug by opening the hass.io webinterface:
mine looks like https://[server]/hassio/addon/c80014cb_ftpbackup

I’m trying to set this up to backup to a folder on my macOS Server via SFTP.

I’m getting an error saying:
“curl: (1) Protocol “sftp” not supported or disabled in libcurl”

@HarmlessSaucer
You are right.
For Raspberry Pi the alpine image curl does not support sftp.
Is ftps an option for you?

curl 7.58.0 (armv6-alpine-linux-musleabihf) libcurl/7.58.0 LibreSSL/2.6.3 zlib/1.2.11
Release-Date: 2018-01-24
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp

1 Like

@leinich Thanks for the heads up - I’ll take a look at alternatives! :slight_smile:

@leinich It is absolutely perfect, easy to install, easy to use and … it works on my RPi3 + Synology NAS :+1::+1:
Great thank you.

Update:
Manually activated - works perfectly
Automation does not work at all, it seems like it is not able to find c80014cb_ftpbackup

- alias: Daily Backup_test
  trigger:
    platform: time
    at: '1:00:00'
  action:
  - service: hassio.addon_start
    data:
      addon: c80014cb_ftpbackup

Update:
Issue solved, I must search repository for my own slug as leinich described a few posts above :grinning:

Hello,

I am one of the happy users that use your add-on. Thanks for providing this to the community.
I would like to ask for an enhancement…

Right now, it creates a backup of /config, puts it in /backup and upload that file to FTP.
I would like if it is possible to just upload the whole /backup folder to FTP.

Maybe you could at a flag in the user-config that says “backup whole backup directory”?

Reason for asking is that I have daily full snapshots configured and I would like to put these on FTP instead of just the /config folder. The snapshots contain much more IMHO…

Hope you are willing to make this change.

Thanks

1 Like

Dear molano,

Your feedback is very welcome.
Currently my free smarthome time is going into migrating into lovelace-ui .
But as soon as I have finished this I will implement your enhancement.
I created an enhancement request for this: https://github.com/leinich/hassio-addons/issues/3

1 Like