I think I don't need to explain what it is Mega or the late Megaupload (uff what times those ...). Currently there are many of us who use Mega as storage for backups of our system, or well, information of any kind.
Today there are graphical applications for everything, but those of us who always use Linux, out of curiosity or to save time, want to know how to achieve the same with the terminal. An example of this is yowsup, to use WhatsApp through the terminal, which saves us from using Wine and then download WhatsApp Plus free, use WhatsApp with Pidgin. or something similar.
The point is that I plan to use a folder in my Mega account to store server backups, which obviously do not have a graphical interface, so ... mmm ... how can I use a script? bashUpload files to a specific folder on my Mega account? That is the question here.
MegaCMD: Mega from Terminal
Fortunately there is megacmd, an application through which (and with commands) we can upload files to our Mega, download, etc.
Let's proceed to install it:
1. First we must download the source:
2. Unzip the file megacmd-master.zip which was what we downloaded, a folder called megacmd-master, we are going to open a terminal inside that folder.
3. Now we go on to install it, in the terminal we write the following:
make sudo cp megacmd / usr / local / bin
3.1. Sure, if you use ArchLinux it is as simple as:
yaourt -S megacmd
4. Done, it's already installed.
And how is MegaCMD used?
First we must create a file in which we will put our account information. That is, the application cannot connect to our account without having the access data (user and password), for this we will create the file: $ HOME / .megacmd.json
nano $HOME/.megacmd.json
There we will put something like this:
{"User": "USUARIO_MEGA", "Password": "PASSWORD_DE_USUARIO_MEGA", "DownloadWorkers": 4, "UploadWorkers": 4, "SkipSameSize": true, "Verbose": 1}
Take into account that the user is the registration email, that is, in my case it would be:
{"User": "myusuarioblabla@gmail.com", "Password": "BLABLABLABLABLABLA", "DownloadWorkers": 4, "UploadWorkers": 4, "SkipSameSize": true, "Verbose": 1}
When we have already put the information, we press save ([Ctrl] + [O]) and exit ([Ctrl] + [X])
Ready now we will see the content from our initial folder:
megacmd list mega:/
That tells me that there is a folder called MEGAsync, which is the one I show in the first image.
If I want to see what is inside a folder, the variation of the previous line is simple, almost obvious, as the folder is MEGAsync:
megacmd list mega:/MEGAsync/
For Download a file instead the parameter list that we used before, now we will use get:
megacmd get mega: /MEGAsync/snapshot1.png / home / myuser /
That will download the file instant1.png, located inside the MEGAsync folder to my Home.
Otherwise, and that is desired upload a file then instead of get we use put:
megacmd put archivo.zip mega:/MEGAsync/
For delete a file would be with delete:
megacmd delete mega:/MEGAsync/instantánea1.png
But the thing does not end here ... if you wish create a new directory, so:
megacmd mkdir mega:/Backups
More MegaCMD features?
Yes 😀
You can still do more, such as synchronizing folders as we do with rsync, for that the parameter is used sync, we can also with move move files from one folder to another, here are the options provided by the application:
I just told elav that this application is very good, to which he replies: «having the desktop client what to use it for«, Right, when you have Mega Sync then MegaCMD loses a bit of sense, but what if we are on a computer without a graphical environment?
I plan to use MegaCMD for backups of a server, which as I said at the beginning, does not have a GUI.
It could also be used to do an infinite number of things through a script, everything depends on what the user and their imagination need.
Your post has caught my attention for a very specific reason, Megasync consumes around 360MB of memory, does MegaCMD consume less?
My MegaSync in idle consumes between 10 and 40 MB. Maybe because I use KDE and that saves me from loading the QT to run it. But 400MB like that is too much, unless you use that amount of memory temporarily while uploading some heavy file.
Right now the MegaSync does not reach 20MB of consumption
MegaCMD consumes much less than MegaSync… and I don't even know how much this 2nd consumes hehe. Keep in mind that MegaCMD is a script without a GUI, that is, zero graphical interface, so consumption will always be lower.
Thanks for answering, from the beginning that high consumption seemed very strange to me, taking advantage of the fact that I just did an installation of Xubuntu I will try Megasync again but also MegaCMD, the fact that the latter does not require a graphical interface is already an advantage
Not at all, thanks to you for reading us 🙂
>> to which he replies: "having the desktop client why use it"
Well, I explain to Elav a use case that works well for me.
Let's say I'm roaming a pc and I have a super slow cnx, but my remote server has good bandwith, I want to download something big from mega but I'm not going to open a browser or run MegaSync with X forwarding, and here comes MegaCmd: I get the url in my local browser from my slow cnx and I run the downloads from the server with good network. Eureka!
Hi. When doing "make" I get this error:
go get github.com/t3rm1n4l/go-mega
github.com/t3rm1n4l/go-mega
.gopath / src / github.com / t3rm1n4l / go-mega / utils.go: 54: buf.Grow undefined (type * bytes.Buffer has no field or method Grow)
Makefile: 14: recipe for target 'build' failed
make: *** [build] Error 2
Do you have any idea where the problem may be?
Thank you very much.
If you use any Debian distribution you must install the following dependencies before running the make command:
aptitude install golang-go git
with that it generates the executable file megacmd which you must copy to / usr / local / bin