Es gibt ein Tutorial auf Github, hier ist es:
MEGAcmd - Command Line Interactive and Scriptable Application
MEGAcmd provides non UI access to MEGA services. It intends to offer all the functionality with your MEGA account via commands. It features synchronization , backup of local folders into your MEGA account and a webdav/streaming server.
See
Usage Examples.
Available packages for MEGAcmd in all supported platforms should be found
here. If the package fails to install, read below for the requirements.
It supports 2 modes of interaction:
- Interactive - A shell to query your actions
- Scriptable - A way to execute commands from a shell/a script/another program
In order to provide those 2 modes, it features one server (MEGAcmdServer), an interactive shell (MEGAcmdShell) and several commands that will launch the non-interactive client (MEGAcmdClient).
See
Usage and
Platform to understand how to use it in your particular system.
Building MEGAcmd
If you wish to build or install MEGAcmd, here are a list of requirements and instructions.
Requirements
The requirements are the same as those for the sdk (usually cryptopp, zlib, sqlite3, cares, libuv, ssl, curl, sodium, readline for platforms
other than Windows. It is recommended to include pcre to have support for regular expressions.
In order to have support for thumbnails and previews, it is highly recommended to have ffmpeg (libavcodec-dev libavutil-dev libavformat-dev libswscale-dev) and mediainfo(libmediainfo-dev + libzen-dev) for media file attributes.
For convenience, here is a list of packages for common Linux Distros and precompiled third party dependencies for other Operative Systems:
- Ubuntu 16.04
- autoconf libtool g++ libcrypto++-dev libz-dev libsqlite3-dev libssl-dev libcurl4-openssl-dev libreadline-dev libpcre++-dev libsodium-dev libc-ares-dev libfreeimage-dev libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libmediainfo-dev libzen-dev
- Ubuntu 18.04
- autoconf libtool g++ libcrypto++-dev libz-dev libsqlite3-dev libssl-dev libcurl4-gnutls-dev libreadline-dev libpcre++-dev libsodium-dev libc-ares-dev libfreeimage-dev libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libmediainfo-dev libzen-dev libuv1-dev
- Debian 9
- libcrypto++ libpcrecpp0v5 libc-ares-dev zlib1g-dev libuv1 libssl-dev libsodium-dev readline-common sqlite3 curl autoconf libtool g++ libcrypto++-dev libz-dev libsqlite3-dev libssl-dev libcurl4-gnutls-dev libreadline-dev libpcre++-dev libsodium-dev libc-ares-dev libfreeimage-dev libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libmediainfo-dev libzen-dev
- In some instanances you may need to run apt install --reinstall build-essential
- Windows
- For Windows, we have recently overhauled the build system and now all the steps are captured in this one script that will acquire and build all dependencies, as well as building MEGAcmd itself, using vcpkg and cmake. To get and use this script, follow these steps in a command prompt:
- git clone --recurse-submodules --branch tag/youChoose https://github.com/meganz/MEGAcmd.git
- cd megacmd/build/cmake
- fullBuildFromScratchOnWindows x64-windows-mega
- MacOS
Getting the source
Ensure you obtain the repository recursively.
git clone
https://github.com/meganz/MEGAcmd.git
cd MEGAcmd && git submodule update --init --recursive
Building and installing
For platforms with Autotools, MEGAcmd can be built and installed with:
sh autogen.sh
./configure
make
make install
- You will need to run make install as root
Note: if you use a prefix in configure, autocompletion from non-interactive usage won't work. You would need to source /YOUR/PREFIX/etc/bash_completion.d/megacmd_completion.sh (or link it at /etc/bash_completion.d)
Alternatively you can build using Qt project located at contrib/QtCreator/MEGAcmd/MEGAcmd.pro.
For Windows/MacOS you will need to place the 3rdparty folder (included in the dependency bundle referenced
above) into sdk/bindings/qt/.
Usage
Before explaining the two ways of interaction, it is important to understand how MEGAcmd works. When you login with MEGAcmd, your session, the list of synced folders, and some cache database are stored in your local home folder. MEGAcmd also stores some other configuration in that folder. Closing it does not delete those and restarting your computer will restore your previous session (the same as megasync won't ask for user/password once you restart your computer).
You will need to logout properly in order to clean your data.
Now let's get into details of the two usage modes. Both modes require that MEGAcmdServer is running. You can manually launch it. Fortunately, you can also open the interactive shell or execute any command and the server will start automatically.
Interactively:
Execute MEGAcmd shell.
Platform section explains how to do that in the different supported systems. You should be facing an interactive shell where you can start typing your commands, with their arguments and flags.
You can list all the available commands with help.
And obtain useful information about a command with command --help
First you would like to log in into your account. Again, notice that doing this stores the session and other stuff in your home folder. A complete logout is required if you want to end you session permanently and clean any traces (see logout --help for further info).
Non-interactively:
When MEGAcmd server is running, it will be listening for client commands. Use the different mega-* commands available.
mega-help will list all these commands (you will need to prepend "mega-" to the commands listed there). To obtain further info use mega-command --help.
Those commands will have an output value != 0 in case of failure. See
megacmd.h to view the existing error codes.
Ideally, you would like to have these commands in your PATH variable (See
Platform for more info). For further info use mega-help --non-interactive.
Usage examples
Here are some examples of use (more info and usage examples are available at the
User Guide).
Notice: the commands listed here assume you are using the interactive interaction mode: they are supposed to be executed within MEGAcmdShell.
- A synchronization can be established simply by typing:
sync /path/to/local/folder /folder/in/mega
This will synchronize the contents in your local and your mega folder both ways.
- You can also set remote backups of a local folder to keep historical snapshots of your files. So simple as:
backup /path/mega/folder /remote/path --period="0 0 4 * * *" --num-backups=10
This will configure a backup of "myfolder" into /remote/path that will be carried out at 4:00 A.M. (UTC) every day. It will store the last 10 copies.
Further info on backups
here.
- You serve a location in your MEGA account via WebDAV:
webdav /path/mega/folder
- Or stream a file in your MEGA account:
webdav /path/to/myfile.mp4
Further info on webdav and streaming
here.
- Download the contents of a shared link:
get
https://mega.nz/#F!ABcD1E2F!gHiJ23k-LMno45PqrSTUvw /path/to/local/folder
Now let's do something more complicated with non-interactive usage using some GNU tools (similar stuff can be easily done in Windows as well):
- We want to provide something crypto secured with only 10 minutes of access:
mega-put /path/to/my/temporary_resource /exportedstuff/
mega-export -a /exportedstuff/temporary_resource --expire=10M | awk '{print $4}'
- Or imagine we'd like to public the enterprise promotional videos of May 2015 that we have previously stored in MEGA:
for i in $(mega-find /enterprise/video/promotional2015/may --pattern="*mpeg"); do
mega-export -a $i | awk '{print $4}';
done