Automate your Linux system drive backup process, sending it directly to your Mega.nz account using the backup-system-drive-to-meganz
script.
-
You need to have
megacmd
already working in your system:- Download the repo from mega.nz linux repo
- If you're only in the command line, you can use
curl
. For example:curl -O https://mega.nz/linux/repo/xUbuntu_23.04/amd64/megacmd_1.6.3-1.1_amd64.deb
- Choose your system and run the command with the proper path from here.
- For more details, you can check their GitHub repo: MEGAcmd GitHub.
-
After installation, try to login. Check out their manual on GitHub: MEGAcmd User Guide. Ensure that
megacmd
is working at this point.
-
Determine System Drive Device Name:
-
Run
lsblk -o NAME,TYPE,MOUNTPOINT
to check your system drive device name. Look for drives that have some partitions with names likeboot
orboot/efi
.Example Output:
nvme3n1 disk ├─nvme3n1p1 part /boot/efi ├─nvme3n1p2 part /boot └─nvme3n1p3 part └─ubuntu--vg-ubuntu--lv lvm /
In this case, the proper name for the system drive will be
/dev/nvme3n1
.
-
-
Script Placement:
- Place
system_backup_to_mega.sh
in a directory only accessible by the root user. - Run
chmod +x /path/to/system_backup_to_mega.sh
to make the script executable.
- Place
-
Modify the Script:
-
Edit the script to set your credentials, disk drive path, and folders for temporary backups.
nano system_backup_to_mega.sh
-
-
Run Manually:
-
Execute the script manually using:
sh system_backup_to_mega.sh
-
Monitor active processes in another terminal window to ensure everything is running correctly. Use
bashtop
or similar tools to do so.
-
-
Automate with CRON:
-
If everything works correctly and you can see your backup file in your Mega.nz account, you can automate the backup process using CRON:
crontab -e
-
Add a new line to execute the script every day at 3 am:
0 3 * * * ~/path/to/system_backup_to_mega.sh
-
-
CRON Timing:
- If you're unfamiliar with setting up CRON timings, you can use online tools like CronTab or simply ask here for guidance.
Using this script, your system will automatically create a backup of your drive and upload it to your Mega.nz account. Always ensure to test backup scripts in a controlled environment before deploying to ensure data integrity and prevent data loss.