Auto copy backup file to nas or google drive

Hi,i take once a month backup of my config using openhab-cli and a rule using cron.The zip file goes to backups folder of my userdata folder.Then i have to go and copy the latest zip to my nas.I just wonder if there is an easy way to aytomate this and automatic move the latest zip to my synology nas…I am a linux noob so be gentle :slight_smile:

There are many ways of doing so.

Don’t know what Synology offers, but there might be some software at that nas that can grab files from other locations. You could create an SMB share, ftp, http or other service that the nas can connect to to grab the file.

You could also do it the other way around (probably easier) and extend the script that you already have to not only create and move the ZIP, but also to upload it to the NAS. That could be by FTP, SMB share or whatever service are hosted on your NAS.

note: in both cases you have to be aware of what services you expose (and to what network) and have a very limited user account to handle the file transfer.

Maybe there is an rsync client/server available for your synology, that would be a very common way to duplicate specific files/directories from one machine to another. rsync has some nice features to sync remote filesystems. It will only transfer (parts of) files which are needed to build the backup on the remote machine, you can use pull to get the backup (much safer than push, the client doesn’t need any authorization on the backup system, as the backup system will pull the data actively)

You could even use rsnapshot, a script, which uses rsync to backup and build a pool of snapshots. rsnapshot will build several stages of snapshots, you can set how many snapshots are stored and how often they are made, e.g. every 10 minutes (5 copies), every hour (4 copies), every day (7 copies), every week (5 copies) and every month (6 copies).
Sou you would be able to get old configuration up to 6 Months, but on the other hand even the latest changes of the last hour.

rsnapshot uses hard links to the files, only different file versions will need additional space, so it’s a small footprint.
rsnapshot will copy the original files instead of a backup zip, it will only copy what’s needed to get the data updated. You will be able to get every file as it was to a specific time and date.