I am Mega user for quite some time now. I have VPS on which I run my blog. Idea was: can I upload my blog/website/database backups to my Mega account daily? So I wish to use Mega as some sort of backup service. It is possible as there is Linux tool that allows operations through your Linux machine to your Mega account. It is called megatools. Mega offers 50G of capacity for free! In most cases, this should be more than enough to backup your websites. You can backup your server to your Mega account! Downside is, that megatools currently don’t offer function such as is rsync – for archive purposes.
Here is how to install megatools – in this case, on CentOS 7:
- You should install some dependencies that megatools is using first.
yum -y install gcc make glib2-devel libcurl-devel openssl-devel gmp-devel tar
- Download megatools archive (latest version can be found HERE)
[root@vps ~]# wget https://megatools.megous.com/builds/megatools-1.9.97.tar.gz
- Unpack package and go to megatools directory.
[root@vps ~]# tar xvzf megatools-1.9.97.tar.gz
- Install Megatools
[root@vps megatools-1.9.97]# ./configure . . . Configured features: docs build: no warnings: no megafs: no (requires fuse) tests: yes (requires glib-2.0 >= 2.34.0) Run make now. [root@vps megatools-1.9.97]# make . . . [root@vps megatools-1.9.97]# make install
- Megatools is installed. Now you should configure it so that will be able to access you Mega account. In your root directory, create file .megarc, that will contain your login information.
[root@vps ~]# vi .megarc add this: [Login] Username = UsernameOrEmail Password = MyPassword [root@vps ~]# chmod 600 .megarc
- Check if megatools can connect to your Mega account
[root@vps ~]# megadf -h Total: 50.0 GiB Used: 2.9 GiB Free: 47.1 GiB
How to use megatools, you can see here. Bellow is simple example how to create new directory on our Mega account that will be used for our server archive files. Copy is done with command megacopy. Command megacopy won’t overwrite existing files nor will delete them.
- Create directory for our backup archives on our Mega account:
[root@vps ~]# megamkdir /Root/BACKUP [root@vps ~]# megamkdir /Root/BACKUP/myarchive
- Copy files to our newly created Mega archive directory
[root@vps ~]# megacopy --local /var/www/mywebpage/ --remote /Root/BACKUP/myarchive/ F /Root/BACKUP/myarchive/public_html/wp-content/uploads/2014/10/000_0776-300x194.jpg F /Root/BACKUP/myarchive/public_html/wp-content/uploads/2014/10/000_0776-900x582.jpg F /Root/BACKUP/myarchive/public_html/wp-content/uploads/2014/10/000_0776.jpg F /Root/BACKUP/myarchive/public_html/wp-content/uploads/2014/10/000_0785-144x144.jpg 100% - 11.6 KiB of 11.6 KiB . . .
You can schedule this operations by adding this lines to your crontab. For example, if you want to copy document root directory of your website daily, you add this to your crontab:
* 0 * * * /usr/local/bin/megacopy --local /var/www/mywebpage/ --remote /Root/BACKUP/myarchive/ >/dev/null 2>&1
I will also create some script for this in the future! 🙂