Cron job to receive regular backup of your hosted sqlite3 db as mail attachement

While hosting debutsav.in, I came to a scenario to get regular backups of the registration db. This would be a regular requirement for anyone working with web, and cares about data security. I went through various blogs available – and let me share the one that helped me great πŸ™‚

The key is to add a cronjob to the linux system – to automate the mailing part. To write the cron job.

# crontab -e 

That would sometimes bring about a confirmation message, otherwise proceed to next step.
You will need a file emailbody.txt that would contain the email body.
IMP: This would mail you the db backup every day at 12:00 am ( sometimes pm πŸ˜€ ).

0 0 * * * mutt -s "Database Backup" -a /path/to/sqlitedb.db -- yourname@yourdomain.ext < /path/to/emailbody.txt

Save and close the file, and you are good to go πŸ™‚

Checklist:
* What if your web hosting provider do not allow emails ?
> You can check that one by running this command:

$ mail yourusername@yourserver.ext

enter a test subject and body – and click ‘.’ to finish of the email body and send the mail πŸ™‚

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s