Month: November 2014

Use plowshare on Linux to upload to mega

Backups I make on my Linux installations I encrypt and backup to cloud services. Mega.co.nz is such a service, which offers 50GB
for free. plowshare is a Linux commandline tool which offers an interface to upload and download from and to a lot of free file host services.
This post will explain how to install plowshare on a Linux host, install the mega module and upload a backup.

Install plowshare

root@web01:~# git clone https://code.google.com/p/plowshare/ plowshare4
Cloning into 'plowshare4'...
cremote: Counting objects: 16977, done.
Receiving objects: 100% (16977/16977), 4.75 MiB | 167 KiB/s, done.
Resolving deltas: 100% (12960/12960), done.
root@web01:~# cd plowshare4/
root@web01:~/plowshare4# make install

Install mega.co.nz module

Execute the following commands to install the mega plugin for plowshare. This will also download and install the source package from openssl for some compilation. The package
name is libssl-dev on Debian, Ubuntu or similar distributions. On Fedora, CentOS or RHEL this is openssl-devel.

git clone https://code.google.com/p/plowshare.plugin-mega plowshare.plugin-mega
cd plowshare.plugin-mega/
apt-get install libssl-dev
make install

root@web01:~# git clone https://code.google.com/p/plowshare.plugin-mega plowshare.plugin-mega
Cloning into 'plowshare.plugin-mega'...
remote: Counting objects: 150, done.
Receiving objects: 100% (150/150), 56.40 KiB, done.
Resolving deltas: 100% (69/69), done.
root@web01:~# cd plowshare.plugin-mega/
root@web01:~/plowshare.plugin-mega# apt-get install libssl-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libssl-doc
The following NEW packages will be installed:
  libssl-dev libssl-doc
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 2,709 kB of archives.
After this operation, 6,229 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libssl-dev armhf 1.0.1e-2+rvt+deb7u13 [1,504 kB]
Get:2 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libssl-doc all 1.0.1e-2+rvt+deb7u13 [1,205 kB]
Fetched 2,709 kB in 2s (1,226 kB/s)
Selecting previously unselected package libssl-dev.
(Reading database ... 75102 files and directories currently installed.)
Unpacking libssl-dev (from .../libssl-dev_1.0.1e-2+rvt+deb7u13_armhf.deb) ...
Selecting previously unselected package libssl-doc.
Unpacking libssl-doc (from .../libssl-doc_1.0.1e-2+rvt+deb7u13_all.deb) ...
Processing triggers for man-db ...
Setting up libssl-dev (1.0.1e-2+rvt+deb7u13) ...
Setting up libssl-doc (1.0.1e-2+rvt+deb7u13) ...
root@web01:~/plowshare.plugin-mega# make install
gcc -Wall -O3 -s src/crypto.c -o mega -lcrypto
install -d /usr/local/share/plowshare4/modules
install -d /usr/local/share/plowshare4/plugins
install -m 755 mega /usr/local/share/plowshare4/plugins/mega
install -m 644 module/mega.sh /usr/local/share/plowshare4/modules

After this we need to register the mega module to the plowshare module registry:

 echo "mega            | download | upload |        |      |       |" >> /usr/local/share/plowshare4/modules/config

After this you can execute the command plowup mega to validate if the installation was a success. The output will have to look similar to:

plowup: you must specify a filename.
plowup: try `plowup --help' for more information.

Encrypt and upload

The file backups takes place in three steps (which assumes that there already is one folder with all the backupped information):

  1. Create a tar.gz archive (tar -czf backup.tar.gz ./backupfolder)
  2. Encrypt the archive with openssl, based on this post (openssl aes-256-cbc -in backup.tar.gz -out backup.tar.gz.aes -pass file:pass.txt)
  3. Upload the archive with plowshare (plowup mega —auth=username:password —folder=”Backups” backup.tar.gz.aes)

Leave a Comment