Posted by

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
cd megatools*
make install

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 = “”

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

DATE=$(date +”{01827cc1628cab5942660499088773e56eb46df7cf4f7207d19f3491caccff3b}Y-{01827cc1628cab5942660499088773e56eb46df7cf4f7207d19f3491caccff3b}m-{01827cc1628cab5942660499088773e56eb46df7cf4f7207d19f3491caccff3b}d”)
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
/home/backup/mega/megatools-1.9.98/megaput $X

# 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.


Leave a Reply

Your email address will not be published. Required fields are marked *