How to back up files from Linux to Gmail?

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 backup and mail it for you.
# vim /usr/bin/backup
copy and paste the following into the file :
cd /backup
rm -rf /backup/*
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 above script we have used compressing utility to compress you backed up data, which will make data small as much 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 send an email from your local system, you must have to configure SMTP server.

Please Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.