How to Make a Backup Script for Shell in Linux

For those who hack a lot of Linux at the command line interface, backing up files such as config files before editing is a good habit to have. IMHO anyway. So to save time, a little script can be written, chmod +x, and placed into /usr/local/bin or some other that users have in their executable shell PATH. I name mine “bu” to make it easy, and it takes one command line argument which is the filename of the file you want to make a backup copy of. It is called by running something like $ bu myfile

Here’s the code. Comments welcome ;) The code creates a timecode based on today’s date and the current time to the second, and appends that to the original filename. The a copy is saved with this new “timestamped” backup filename, right in the same directory. Easy-peasy! 

#!/bin/bash
OLDFILENAME=$1
DATECODE=$(date +%Y%m%d)
TIMECODE=$(date +%H%M%S)
NEWFILENAME="${OLDFILENAME}_backup${DATECODE}-$TIMECODE"
cp $OLDFILENAME $NEWFILENAME
SUCCESS=$?
if [ $SUCCESS -eq 0 ];then
 echo "OK! Copied \"$OLDFILENAME\" to \"$NEWFILENAME\""
else
 echo "FAIL! You'll need to try again!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
fi

Posted under Linux

Update Microsoft Windows Defender manually

Microsoft makes manual download of update files easily accessible at this link:

http://go.microsoft.com/fwlink/?linkid=70631

This will download a file called Mpas-fe.exe
Try to save the file in a location that you can get to easily with a command prompt. (ie. C:\ )
Then, open a command prompt and run the program using the -q switch. It looks like this:

Mpas-fe.exe -q

The program will run quickly, and won’t give you any kind of confirmation that it has run or finished.

Open the Microsoft Windows Defender window to see what date your definition files have. This is how you can be sure that the update was successful.

IMPORTANT: The above info applies ONLY to 32-bit Operating Systems. For those of you using 64-bit platforms, see the full scoop here:

http://support.microsoft.com/kb/923159

Posted under Freeware, Microsoft

Set time at command line in Linux

This works for all Linux flavors as far as I know:

The date command is used to set the system clock using the switch -s and the format MMDDhhmmYYYY (where MM=month, DD=day, hh=24-hour hour, mm=minute, YYYY=year)

The following example sets the date to January 5th 2007, 1:15 PM:

# date -s 010513152007

Posted under Linux

This post was written by Content Curator on March 9, 2007

Tags: , , , , , , , , , , , , ,