Mega backup: copies in the cloud in GNU / Linux.

Mega backup automatizado.

Mega Backup script

I guess we all know Mega, the new service of Kim Dotcom the former head of MEGAUPLOAD. This service is interesting for several reasons, the main one is that it offers 50 GB for free to any user, other lesser known reason is that it has line tools very powerful commands for directories synchronized with the cloud.

In this article I will show how we can perform automated backups some folders on your GNU / Linux system in the cloud Mega. Create a copy of your files synchronizing only new files on each copy.

Preparing mega needed to backup.

Mega Account

The first thing you need is an account of mega I will use an account with the following information.

  • User: mega@aplicacionesysistemas.com
  • Password: LaPasswordDeMega

Folders to save

I realize the example Mega backup the following folders.

/home/nacho/Imágenes
/home/nacho/Documentos

Mega destination folders

The target for mega backup folders must be created in Mega previously I do to make it easier for the website that is me.

imagenes
documentos

Megatools

They are the tools that offers to handle mega mega cloud from the command line.
To install run the following commands.

Ubuntu and derivated

sudo add-apt-repository ppa:megous/ppa
sudo apt-get update
sudo apt-get install megatools

For users of ubuntu 14.04 you have to edit a line in the sources.list file, and the project is abandoned and no trusty version still required version works fine.

sudo nano /etc/apt/sources.list

We edit the lines that put

deb http://ppa.launchpad.net/megous/ppa/ubuntu trusty main
deb-src http://ppa.launchpad.net/megous/ppa/ubuntu trusty main

and leave it follows

deb http://ppa.launchpad.net/megous/ppa/ubuntu precise main
deb-src http://ppa.launchpad.net/megous/ppa/ubuntu need main

Press Control + X to exit nano and say yes we want to save. With Imanol, Manolo and Xembi by indicating the problem and how to solve.

Other distributions

For other distributions is best to go to the megous of page where you can download the binary for your distribution.

The megarc file.

To know that MegaTOOLS account where you make the backup file is created. Megarc into the root folder of the user who will have to perform the backup, if you create the user root / root if user create / home / user I'm putting in my user folder.

touch /home/nacho/.megarc

Edit the file to make it with the following structure. Change the username and password for yours.

nano /home/nacho/.megarc

And put the following text in the file. Remember to change the username and password for yours.

[Login] 
Username = mega@aplicacionesysistemas.com
Password = LaPasswordDeMega

Press Control + X to exit nano and say that if we keep.

The log file to check the copies.

Create a log file to check if the backup is done mega.

touch /home/nacho/logmega

EL script megabackup

To set up the things we want to save create a bash script called Megabackup , believe it in your user folder which you have to use.

touch /home/nacho/megabackup

Edit the file by putting the following to your liking by changing the folders to save source code and destination folders.

Read the script is said to have no trouble understanding.

#!/bin/bash
# MEGA BACKUP
# 
# :: Dependencies : megatools
##### VARIABLES ######
# Folder origin1 local data
loc1=/home/nacho/Imágenes/ 
# Target folder origin1 data remotely must be previously
# created in mega you can create via Web of mega.
remot1=/Root/imagenes 
# If you want to save more create more folders more origins and destinations. 
loc2=/home/nacho/Documentos # Carpeta origen2 site
remot2=/Root/documentos # Folder mega destination2 must already be created.

# We store the log the start time of the backup
echo "Starting backup ($(date))" >> /home/nacho/logmega

### Home Copy first origin (this part will repeat all the folders we want to copy to mega
##########################################
# Synchronizing with mega pictures
echo "Starting backup images" # message on screen
megasync --local $loc1 --remote $remot1 # We synchronize the folder
# message on the screen to know that I just sync the first folder
echo "*****************************************************"
echo "*****************************************************"
echo "*****************************************************"
echo "*****************************************************"
echo "*****************************************************"
echo "Tuning the Images for backup on mega"
echo "*****************************************************"
echo "*****************************************************"
echo "*****************************************************"
echo "*****************************************************"
echo "*****************************************************"
### End the backup of the first folder
##########################################

##########################################
### Starting the second copy of the source
echo "Starting backup Documents"
megasync --local $loc2 --remote $remot2
# message on the screen to know that I just sync the second folder
echo "*****************************************************"
echo "*****************************************************"
echo "*****************************************************"
echo "*****************************************************"
echo "*****************************************************"
echo "Documents sync with backup on mega"
echo "*****************************************************"
echo "*****************************************************"
echo "*****************************************************"
echo "*****************************************************"
echo "*****************************************************"
### End backup second folder
##########################################

##########################################
### Now we pour the log output messages
echo "Wait a few seconds ......" # This message takes a little screen wil
free ="$(megadf |grep Free)" # find out the free space on mega
ocu="$(megadf |grep Used)" # find out the space used by mega
echo "You space is $free" # message on the screen with information on mega clearance
# we noted in the log copies in the safety trigger log /home/nacho/logmega
echo "Copy Ended ($(date)) occupied space ($ocu) space ($free)" >> /home/nacho/logmega
exit

After creating the script you have to give execute permissions

sudo chmod 755 /home/nacho/megabackup

to test if it works run it from the command line

./megabackup

My problems are that he gave me for not having created the folders in mega or the names of the folders did not coincide. If you have many files , yo 25GB, It may take several days to back.

Automate with cron

Run the following command

crontab -e

Finally yourselves the following line to the user synchronization yours and path of the script takes place at four in the mañana.Cambia for yours.

0 4     * * *   nacho   /home/nacho/megabackup

Save and already have automated backups in the cloud mega. daily.

The script just add new documents that you generated from the previous copy with the first copy that although much later successive copies are much faster.

Remember to look occasionally the log to see if copies are made.

If you liked the article I would ask the favor of pulsaseis on the buttons below to share on social networks. Thank you very much in advance.


About Ignacio Alba Obaya

Microcomputer and Technical Training for Employment. Lover of new technologies. Manager GNU / Linux and Windows.

13 comments:

  1. Very good; After the disappointment with UbuntuOne I decided to synchronize with Mega.
    Something, use 14.04 and it seems that the repository is not enabled for trusty. I think I solved modifying the repository and putting to specify. Testing and currently works 100%.
    Very clearly explained.
    Thanks.
    HEALTH!

  2. Thank you very much for the input, I've been very helpful.
    I wanted to ask if you know how to enable parallel increases and retry failed uploads.

    For parallel increases, he viewed this command:
    ls *.7z | xargs -n1 -P4 megaput -u [dirección_correo_electrónico] -p [password]

    I've modified to upload all the directories and files it finds:
    ls *.* | xargs -n1 -P4 megaput -u …

    but not work, parece que solamente me ha subido los archivos sueltos y ha pasado de las carpetas 😉

    I saw it on the next page:
    http://www.exvagos.com/showthread.php?t=530204

    Would you know how to fix it?

    Thanks in advance and best regards.

  3. You go to the program “Sotware and updates” Brands “Otro sofware”, selecionas putting repository “megous”, edit it and “Distribution” you change “trusty” by “precise” to see if it works.

Leave a Reply

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