In this guide we will configure a nightly server backup running Bitnami with HiDrive Pro for FTP storage.
Please note that only HiDrive Pro supports FTP access. Lower tariffs will not work with this setup: https://www.ionos.com/office-solutions/hidrive-cloud-storage
Before we get started login to your HiDrive Pro account at https://hidrive.ionos.com
Go to Settings > Account. Under “Access rights and protocols” click the edit button and uncheck the “Only use encrypted connections” button.
Now firstly you will want to login to your server using SSH and create the following folders: /scripts and /tmpbackup
Now proceed with the steps below:
First create /scripts/backup.sh with the following code:
/bin/zip -r /backup/$(date +\%Y-\%m-\%d).zip /opt/bitnami
This code will stop your web services and then create and store a backup with today’s date in /backup. It is best to stop web services while this is taken to ensure no data is lost. Since Bitnami is self-contained the entire /opt/bitnami folder is backed up. These folders can be adjusted accordingly if your data is stored elsewhere.
Next create your 2nd script at /scripts/ftp.sh with the following code:
ftp -n -i $SERVER <<EOF
user $USERNAME $PASSWORD
rm -rf *.zip
This code connects to your ftp storage on HiDrive and transfers the backup previously run. Once the transfer completes it then deletes the backup from your server’s local storage.
Next make sure to give needed execute privileges to your new scripts:
chmod +x /myscripts/*
To complete the automated backup process we will now configure a cronjob for each script:
0 2 * * * /myscripts/backup.sh
0 3 * * * /myscripts/ftp.sh
This will have each script run daily at 2am and 3am. A delay is put in for the ftp transfer to ensure the previous archive process completes before the transfer starts. This is more of a personal preference as this could be combined into a single script. I prefer it this way as to spread out the load on the server as backup.sh will stress the CPU and Disk I/O while ftp.sh will cause load on the Network.