Solarum Tech Boards Back to Solarum.com
September 10, 2010, 04:17:48 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome to the Solarum Tech Boards, get in there and ask/answer some questions!
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Simple PERL file backup script  (Read 857 times)
Laz
Solarum Admin
Administrator
Jr. Member
*****

Karma: +2/-0
Offline Offline

Posts: 59


SunLitLaz
View Profile WWW Email
« on: July 28, 2007, 01:53:19 AM »

I am one of those type of people that like to make backup copies of files before I tinker with them, especially when I am modifying important files like system stuff.  It's always a good idea to make a backup copy before you edit something so you can put it back if you break it.  For that reason, I wrote this simple little PERL script that I then put somewhere in my path so I can run it from anywhere.  I call it simply "bu" so that it's easy to type and use.  What it does is copy the target file you specify, to a file of the same name only with a date stamp appended to it.  I have found this to be a really handy tool, so I thought I would share.

Code:
#!/usr/bin/perl

if ($ARGV[0] eq "") {
  die("No file specified!\n");
} else {
  `cp -p $ARGV[0] $ARGV[0].\`date +%m%d%y_%H%M%S\``
}

Check it out, I hope you find it as useful as I have.
Logged

Do you know what the chain of command is? It's the chain I go get and beat you with til you understand who's in rutting command here!
mack
Jr. Member
**

Karma: +0/-0
Offline Offline

Posts: 68



View Profile WWW
« Reply #1 on: July 28, 2007, 10:04:31 AM »

You are putting into practice here one of the cardinal rules of systems administration.. always create a path to return ... just in case you break something when making changes.  I always make a backup of config files before making changes, but it never dawned on me to create a script that could make this backup with a timestamp.  This is very, very nifty.  THANK YOU.
Logged

He is no fool who gives up what he cannot keep to gain what he cannot lose --Jim Elliot, missionary martyr
Pages: [1]   Go Up
  Print  
 
Jump to:  

  Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC  
Page created in 0.111 seconds with 17 queries.