Below steps shows you how to back up files from Linux to Gmail –
# cd / && mkdir backup
Now, you need to create a script, which will perform back up and mail it for you.
# vim /usr/bin/backup
copy and paste the following into the file :
# cd /backup # rm -rf /backup/* # cp LIST_OF_FILES . # tar zcf backup.tar.gz * # echo | mutt -s “Linux Backup” [email protected] -a backup.tar.gz
Here, you have to change
LIST_OF_FILES string to the list of the files you want to be backed up separated by space, and change
[email protected] to your own Gmail account.
In the above script, we have used compressing utility to compress your backed-up data, which will make the data small as possible. After compressing it,
mutt will send an email. As you can see in the script we are compressing the data files to make them as small as possible. Also, we are using
mutt to send emails, so you need to install it.
Finally, make the script executable and need to set a cron job.
# chmod +x /usr/bin/backup # crontab -e 00 00 * * * /usr/bin/backup
Save and exit it and run below command to make it live.
# service crond restart
Please Note: To back up files from Linux to Gmail, you must have to configure the SMTP server.