View Single Post
  #1   (View Single Post)  
Old 9th February 2010
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,131
Default Easily retrievable configuration file backup with Gmail

Shortly after I accepted an invitation for a Gmail account, (thank you Joost), I found it very easy to send configuration files to my account.

A simple command from the command line to mail me a backup of my pf.conf file:

Code:
# mail -s 'Parmenides: pf.conf' g.w.bush@gmail.com </etc/pf.conf
I created a label BAK to archive these configuration backup mails and some time later I found an easy way to automatically apply this BAK label.

There are two requirements:
  1. Upon mailing, append a plus sign followed by the label to the 'TO: address'.

    So instead of just using g.w.bush@gmail.com use g.w.bush+BAK@gmail.com.

    Example:
    Code:
    $ mail -s 'Hercules: xorg.conf' g.w.bush+BAK@gmail.com </etc/XII/xorg.conf
  2. Create a Gmail filter to automatically apply a Gmail label

    In the 'Create Filter' dialogue box, enter +BAK in the To: field.
    After clicking 'Next step' you will see something like this:

    Code:
    Choose action - Now, select the action you'd like to take on messages
    that match the criteria you specified.
    When a message arrives that matches the search: to:(+BAK), do the following:
    
    [ ] Skip the Inbox (Archive it)
    [ ] Mark as read
    [ ] Star it
    [ ] Apply the label:   
    [ ] Forward it to:
    [ ] Delete it
    [ ] Never send it to Spam
    Check 'Apply the label'. You can either use an existing label or create a new one, which even doesn't have to be BAK.
    Also select 'Never send it to Spam' to eliminate the chance you backup ends up there, and gets deleted after 30 days.

    After you have finished the last filter creation steps, you are ready to use this easy way of creating backups of all your carefully handcrafted configuration files.

Real life example

Yesterday the following BAK mail saved me a lot of trouble when I installed a new OpenBSD snapshot, and wanted to preserve my original disklabel layout:

Code:
Charlie Root             to me show details Jan 17
	
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/wd0a     61.4M   32.0M   26.3M    55%    /
/dev/wd0m      6.5G    2.8G    3.4G    44%    /backup
/dev/wd0e     19.7G    2.8G   15.9G    15%    /home/j65nko
/dev/wd0d      502M    2.0K    477M     0%    /tmp
/dev/wd0k      3.9G    418M    3.3G    11%    /usr
/dev/wd0l      3.9G    210K    3.7G     0%    /usr/local
/dev/wd0f     1005M    3.0M    952M     0%    /var
/dev/wd0h      502M    122K    477M     0%    /var/log
/dev/wd0g      502M    4.0K    477M     0%    /var/tmp
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump

Last edited by J65nko; 9th February 2010 at 04:19 AM. Reason: Changed pietjepuk to g.w.bush as the example gmail account
Reply With Quote