Remove old backups on mega.nz megatools

Easy way to remove old backup files from MEGA.NZ using megatools and bash.

Just make some changes you need and add it to cron.daily

# cat /root/bin/mega_nz_remove_old.sh


#!/bin/bash
#
# mega_nz_remove_old.sh (needs megatools to be installed)
#
# Run this script daily via cron
#
# Path to backup directory on mega.nz
FILES="/Root/backup/"
# Date x days ago (default is 7)
OLD=`date +"%Y-%m-%d" --date='7 days ago'`
# List old files and remove
megals -h $FILES | grep $OLD | xargs megarm > /dev/null 2>&1