Back up files to email?

I've got eight sites running on my Linode at the moment. Three are mine and the remaining 5 are for others. I have no current back-up strategy and it's starting to worry me.

All the files are in one /websites directory. Simple enough. And they're all relatively small.

I'd like to recursively zip or tar.gz that dir and immediately fire that file off to my email account (on gmail) once a day.

I can do the zipping. I can do the scheduling. I just can't do the email sending. Any tips there?

I'm also not sure if what I'm planning is a good idea. I think I'd rather have many duplications in my gmail account (I'm allowed 25gigs and easy they're enough to clean up) than various rsync diffs that need a PHD to restore.

6 Replies

I use this occasionally.. Perhaps it could help you?

http://www.webcheatsheet.com/PHP/send_e … Attachment">http://www.webcheatsheet.com/PHP/sendemailtexthtmlattachment.php#Attachment

The file was successfully sent!"; 
} else { 
die("Sorry but the email could not be sent. Please go back and try again!"); 
} 
?>

I haven't tried this but plan to

!/bin/bash

tar -zcf /tmp/backup.tar.gz /home/calvin/files

echo | mutt -a /tmp/backup.tar.gz -s “daily backup of data” calvin@cnh.com

or you can use GmailFS.

This perl script works excellent for me:

http://www.pastebin.ca/1377411

Just save it to /usr/local/bin/sendEmail and make it executable. It will give you usage if you run it without arguments.

Thanks for all the suggestions. I'm going to have a stern look at them all after work.

I think I won't be doing the GmailFS route for one main reason: I don't really want my server being able to access my Gmail. That's one of the main reasons I don't host my own email on my VPS; I don't want my entire life rooted if one of my VPSs does.

Right. I've been dicking around with mutt and kept running into maximum attachment issues.

The fool would edit his config. I fixed the attachment.

Here's the command I'm firing off:

rm sites.7z && 
7z a -t7z -m0=lzma -mx=9 -xr@ex sites.7z /websites && 
echo | mutt -a sites.7z -s "VPS Backup" me@email-address.com

And I've got a file called ex that ignores things I couldn't care less about losing (for fairly obvious reasons):

.bzr
.svn
.git
*.pyc
amedia
logs
*.log

Using 7z over gzip made a 60% difference, getting the attachment well under the sendmail barrier.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct