Cloud Storage: FTP / SFTP How to

FTP (port 21) and SFTP (port 22) are supported, using your login and password in the Cloud Storage panel.

 

Example Backup Script:

This script will sync backups from a directory on your server. You will need rsync, mutt, and curl.

# You must have mutt installed for email alerts and curl installed to upload the files to the ftp server.
# Change settings to match your settings!
# !/bin/bash

# Date for files
DATE=`date +%A_%b_%d_%Y`

# Home Directory
HOMEDIR=/backup

# FTP Username
USERNAME=username

# FTP Password
FTPPASSWORD=password

# FTP Hostanme or IP Address
HOSTNAME=127.0.0.1

# Server Name
SERVERNAME=server1

# Send Confirmation email to this address
EMAILADDRESS1=user@domainname.com

# Uptime
UPTIME=`uptime`

#Make Directory
mkdir /backup/$DATE >> /backup/$DATE.log

# MySQL
DBUSER=database user
DBPSWD=database password
DATABASE1=database

# Touch Log file
echo "-+-+-+-+-" >> $HOMEDIR/$DATE.log
echo $DATE >> $HOMEDIR/$DATE.log
echo "-+-+-+-+-" >> $HOMEDIR/$DATE.log
echo $UPTIME >> $HOMEDIR/$DATE.log

# Backup Databases
mysqldump -u $DBUSER -p$DBPSWD $DATABASE1 > $HOMEDIR/$DATE/$DATABASE1.sql >> $HOMEDIR/$DATE.log

# rsync Meta partition to $BACKDIR/$DATE/
rsync -a -v /var/www/ /backup/$DATE/www/ >> /backup/$DATE.log

# TAR UP FILES
tar -czf $HOMEDIR/$SERVERNAME$DATE.tar.gz /backup/$DATE >> /backup/$DATE.log

# Send backup files to redundant back up server
curl -T $HOMEDIR/$SERVERNAME$DATE.tar.gz ftp://$USERNAME:$FTPPASSWORD@$HOSTNAME:21/$SERVERNAME$DATE.tar.gz >> $HOMEDIR/$DATE.log


#Mail user when complete
mutt -s "Back up complete $UPTIME" -c $EMAILADDRESS1 -i $HOMEDIR/$DATE.log >> $HOMEDIR/$DATE.log