Mega is a cloud storage and file-hosting service provided by Auckland-based Mega Limited. Users primarily access the service through web-based applications. Mega is renowned for its robust security, as all files are encrypted locally before being uploaded. This end-to-end encryption ensures that no unauthorized party, including Mega Limited employees, can access the files without the encryption passkey. The service is also notable for its generous 50 GB storage allowance for free accounts.
Here are some key features of the MEGA cloud service:
- 50 GB of free cloud storage
- End-to-end encryption
- Cross-platform compatibility (Linux, Windows, macOS, Android, iOS)
- Selective sync functionality
- Web browser accessibility
Installing MEGA in Linux
Unlike Google Drive, MEGA provides both a substantial 50 GB of free storage and a dedicated desktop client for Linux. Binaries are readily available, simplifying the installation of MEGASync, the desktop sync client for MEGA, across all major Linux distributions. You can obtain the MEGASync binary package from the link below. Choose the version corresponding to your Linux distribution (or the one upon which your distribution is based). The MEGASync client functions similarly to the Dropbox client.
Create a MEGAsync account and sign in.
[Image: MEGA login screen]
Create a “MEGAsync” folder in your Linux home directory and a “full_MySQL” folder within your MEGA cloud storage. The “full_MySQL” folder will serve as the destination for MySQL/MariaDB backups. Files placed in the local “MEGAsync” folder will be synchronized to the “full_MySQL” folder in your MEGA cloud storage. (You can create additional folders for other purposes, such as Koha and Wordpress backups, as needed.)
[Image: File structure showing local “MEGAsync” folder and MEGA cloud storage folder]
Configure Sync Permissions:
Grant sync permissions to the relevant folders within the MEGAsync settings.
[Image: MEGAsync settings screen showing sync permissions]
Automate MySQL/MariaDB Backups:
Open Applications > Accessories > Terminal.
Type
crontab -eand press Enter.Select a text editor when prompted. Nano is a suitable choice.
Navigate to the bottom of the cron file using the down arrow key.
Copy and paste the following command to schedule a full MySQL/MariaDB backup at 4:30 PM daily:
130 16 * * * mysqldump -uroot -p'admin@lib' --all-databases --single-transaction --quick --lock-tables=false | xz > /home/mahesh/MEGAsync/full_MySQL/full-backup.sql.xzTo back up specific databases, use the following commands, adjusting the database names and paths accordingly:
- For Koha_library database backup:
130 16 * * * mysqldump -uroot -p'admin@lib' koha_library | xz > /home/mahesh/MEGAsync/koha_backup/koha_library.sql.xz- For Wordpress database backup:
130 16 * * * mysqldump -uroot -p'admin@lib' wordpress | xz > /home/mahesh/MEGAsync/wordpress/wordpress.sql.xzImportant: Replace
admin@libwith your actual MySQL/MariaDB password and modify the destination folder paths if necessary.Save the cron file by pressing Ctrl+O, followed by Enter.
Exit the cron editor by pressing Ctrl+X.
Alternative Approach:
Create a bash script and schedule it using crontab.
Create a bash script (e.g., “uploadtomega.sh”) using:
1sudo nano /usr/local/bin/uploadtomega.shAdd the following content to the script, customizing the database names, passwords, and paths as needed:
1 2 3 4 5#!/bin/bash mysqldump -uroot -p'admin@lib' --all-databases --single-transaction --quick --lock-tables=false | xz > /home/mahesh/MEGASync/full_MySQL/full-backup-$(date +%d-%m-%Y-%H.%M).sql.xz mysqldump -uroot -p'admin@lib' koha_library | xz > /home/mahesh/MEGASync/koha_backup/koha_library-$(date +%d-%m-%Y-%H.%M).sql.xz mysqldump -uroot -p'admin@lib' wordpress | xz > /home/mahesh/MEGASync/wordpress/wordpress-$(date +%d-%m-%Y-%H.%M).sql.xzSave the script and make it executable:
1sudo chmod a+x /usr/local/bin/uploadtomega.shEdit the root user’s crontab:
1crontab -eAdd the following line to schedule the script execution at 4:30 PM daily:
130 16 * * * /usr/local/bin/uploadtomega.shSave and exit the cron editor.
After setting up the automated backups, you can find the backup files in your local “MEGAsync” folder after 4:30 PM each day. These backups will be synchronized to your MEGA cloud storage as well.
Reference: https://help.ubuntu.com/community/CronHowto#Crontab_Example