I wanted to implement an auto upload of backups for my vestaCP sites and currently have a working prototype which I plan to improve on. I chose Mega due to the free 50gb of storage space.
1. Install prerequisites for Mega Tools
yum -y install gcc make glib2-devel libcurl-devel openssl-devel gmp-devel tar automake autoconf libtool wget asciidoc -y
2. Install Mega tools, you can find the most recent version here
tar -xzvf megatools*.tar.gz
3. Now you will need to create a .megarc file within the admin or which ever account you are running this forms home folder. This stores your login details
Username = “firstname.lastname@example.org”
Password = “fakepassword123”
What I then decided to do was to include some bash at the base of /usr/local/vesta/bin/v-backup-user just before the end ‘exit’
#Get today’s dates
echo “Starting upload for $MOREF” >> $BACKUP/$user.log
# For each backup created
for X in /home/backup/*.tar; do
echo “Uploaded $X” >> $BACKUP/$user.log
# Location to mega tools install and then the file to be uploaded
# Move the uploaded file into the archive folder
mv $X /home/backup/archive
echo “Finished uploading backup” >> $BACKUP/$user.log
Now when ever this backup script is called it will upload the created file.
As mentioned before this is the first prototype so complete crap although I’m refactoring it now so that it is not such a hack but in the mean time people may find it useful!
- Refactor into separate script
- Add forms to the web control panel to save having to do anything but click a few buttons
- Add easy options to specify the save / archive locations
- Move it to Github if necessary
- Enable support for multiple different cloud hosts.