Go Back   DaemonForums > Miscellaneous > Guides

Guides All Guides and HOWTO's.

Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 9th February 2010
J65nko J65nko is offline
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 3,503
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:

# 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.

    $ 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:

    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:

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


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Taking your sed(1) skills beyond the easily swallowed 's/x/y/' porridge J65nko Guides 5 3rd February 2010 08:23 PM
PHP read file contents - Maximum file size cksraj Programming 1 21st September 2009 11:38 AM
backup freeBSD 7.0 using Backup Exec ccc FreeBSD General 2 25th April 2009 09:23 PM
backup drive to image file milo974 OpenBSD General 8 14th August 2008 02:01 PM
Kernel configuration file ignored? FWS FreeBSD Installation and Upgrading 16 26th June 2008 10:28 AM

All times are GMT. The time now is 06:38 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick