Incremental Linux backup to FTP-server

By Nisse Pettersson at January 30, 2010 04:16
Filed Under: Technical
Share on Facebook

I’m running a Macedonian e-date site (www.ergeni.com.mk) as a small project just for fun and it’s running on Ubuntu Machine. I need backup offcourse and found a nice script. I’m not the author of this script and i’m not interested in taking credit for it. It works fine and is fast. Just edit the variables and run the script.

#!/bin/sh
# System + MySQL backup script
# Full backup day - Sun (rest of the day do incremental backup)
# Copyright (c) 2005-2006 nixCraft <http://www.cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# Automatically generated by http://bash.cyberciti.biz/backup/wizard-ftp-script.php
# ---------------------------------------------------------------------
### System Setup ###
DIRS="/home /etc /var/www"
BACKUP=/tmp/backup.$$
NOW=$(date +"%y-%m-%d")
INCFILE="/root/tar-inc-backup.dat"
DAY=$(date +"%a")
FULLBACKUP="Sun"
### MySQL Setup ###
MUSER="mysql-user"
MPASS="mysql-password"
MHOST="localhost"
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
GZIP="$(which gzip)"
### FTP server Setup ###
FTPD="/ergeni"
FTPU="ftp-username"
FTPP="ftp-password"
FTPS="ftp-hostname"
NCFTP="$(which ncftpput)"
### Other stuff ###
EMAILID="nisse@nissesblog.se"
### Start Backup for file system ###
[ ! -d $BACKUP ] && mkdir -p $BACKUP || :
### See if we want to make a full backup ###
if [ "$DAY" == "$FULLBACKUP" ]; then
  FTPD="/home/vivek/full"
  FILE="fs-full-$NOW.tar.gz"
  tar -zcvf $BACKUP/$FILE $DIRS
else
  i=$(date +"%Hh%Mm%Ss")
  FILE="fs-i-$NOW-$i.tar.gz"
  tar -g $INCFILE -zcvf $BACKUP/$FILE $DIRS
fi
### Start MySQL Backup ###
# Get all databases name
DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')"
for db in $DBS
do
 FILE=$BACKUP/mysql-$db.$NOW-$(date +"%T").gz
 $MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS $db | $GZIP -9 > $FILE
done
### Dump backup using FTP ###
#Start FTP backup using ncftp
ncftp -u"$FTPU" -p"$FTPP" $FTPS<<EOF
mkdir $FTPD
mkdir $FTPD/$NOW
cd $FTPD/$NOW
lcd $BACKUP
mput *
quit
EOF
### Find out if ftp backup failed or not ###
if [ "$?" == "0" ]; then
 rm -f $BACKUP/*
else
 T=/tmp/backup.fail
 echo "Date: $(date)">$T
 echo "Hostname: $(hostname)" >>$T
 echo "Backup failed" >>$T
 mail  -s "BACKUP FAILED" "$EMAILID" <$T
 rm -f $T
fi

 

Then you need to add this job to crontab. Run the following command.

crontab –e

 

Add a new line to run the file at midnight.

@midnight /path/to/script.sh >/dev/null 2>&1

 

And there you go, a fully working backup system. To restor all you need to do is to extract the files from the ftp server to the same location.
Download the document below and edit.

backup-job.txt (1,97 kb)



Send e-mail with telnet

By Nisse Pettersson at January 18, 2010 06:05
Filed Under: Technical
Share on Facebook

For troubbleshooting it could come in handy to send an e-mail with telnet. It's easy as pie.

Start with running telnet and connecting to a smtp-server.

telnet smtp.microsoft.com 25

Then you get some text back "220 ESMTP". You need to present yourself to the server. You need to give the server the domain of the email adress you are using as a sender.

HELO nissesblog.se

Start typing your from email

MAIL FROM:nisse@nissesblog.se

then the recipient.

RCPT TO:bill.gates@microsoft.com

Now we need to add som text to the message. you can also add a subject.

DATA
Hey Bill, could I have some of your money?
.
// note the single dot, it's needed to tell the server that this is the end of the message

Then all you need to do is to leave with:

QUIT


Uninstall button missing in Windows Vista

By Nisse Pettersson at January 03, 2010 07:44
Filed Under: Technical
Share on Facebook

When you click the application you wish to uninstall in Add/remove programs under control panel you need to reset the folder views in vista. Follow these steps.

  1. Open RegEdit
  2. Browse to HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\
  3. Remove Bags registry key
  4. Remove BagMRU registry key
  5. Close RegEdit
  6. Log off, restart
  7. Login and go to folder options, make sure remember each folder's view settings
  8. Restart computer.

This 8 steps is quite simple. I found the solution on this blog.



Implement ObjectListView in your Winforms application

By Nisse Pettersson at January 02, 2010 06:02
Filed Under: Code
Share on Facebook

I'm developing an inventory software and I was using a listview component. But I do need to be able to change the sorting. Microsft have whitepaper on how to do this. Started reading and then gave up. Did a google search and found ObjectListView. Love at first sight!

This DLL-package is what I was looking for and it's a really nice application. NOTE: This is an open source and is licensed under GPL

Since the getting started guide on their homepage is awsome i'll just link to that page. Get it on!

Technorati-taggar: ,,


Solution for error: BlogEngine is not defined

By Nisse Pettersson at December 31, 2009 11:41
Filed Under: Technical, Code
Share on Facebook

I've upgraded my blog to BlogEngine 1.5.0.7 and then I got a Java Error saing BlogEngine is not defined. The solution is the following.

Download the latest version from codeplex.
Extract blog.js and open it in your favorite editor and look at the code.

// global object
BlogEngine = {
    $: function(id) {
        return document.getElementById(id);
    }

 

The first row is to be deleted, so the start of the file will look like this.

BlogEngine = {
    $: function(id) {
        return document.getElementById(id);
    }

 

Upload the file and restart your .NET application. Edit your Web.Config to get the server to recompile the site.

Technorati-taggar: ,


32-bit ODBC in Windows 2008 64-bit Enviroment

By Nisse Pettersson at December 21, 2009 00:29
Filed Under: Technical
Share on Facebook

I'm installing a new database server and the application is using the 32bit ODBC-connections and the server is a 64-bit SQL. To configure 32-bit ODBC connections hit run and paste the following command.

%windir%\SysWOW64\odbcad32.exe


Howto implement google maps and a marker

By Nisse Pettersson at December 09, 2009 05:59
Filed Under: Code
Share on Facebook

I'm developing a site for a customer who wish to have  a map of his stores and a marker as well. Googles new v3 API of google map is what i'm using since it's newer and hade a nice look and feel than v2.

In my application i'm reading the coordinates from a database but for this example we will use static. Paste the following code in your <HEAD> secion.

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
 <script type="text/javascript">
  function initialize() {
    var myLatlng = new google.maps.LatLng(<? echo $clsShop->LatLong;?>);
    var myOptions = {
      zoom: 13,
      center: myLatlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    
    var marker = new google.maps.Marker({
        position: myLatlng, 
        map: map,
        title:"Hello World!"
    });   
  }


</script>

In your <BODY> tag we will load the map with the onLoad command and unload it when we leave. Use the following tag.

<body onload="initialize()" onunload="GUnload()">

 

Then all you need to do is to create a <div> with id = map_canvas where you wish to place the map. You can use the following example.

<div id="map_canvas" style="width: 220px; height: 220px"></div>

 

Then you're all set and google maps will load. If not you might need sign up for the google API. For more examples you can check out googles own example gallery



Force removal of Visual Studio 2008

By Nisse Pettersson at December 06, 2009 23:37
Filed Under: Technical
Share on Facebook

I've canceled my installation of Visual Studio 2008 and when I now try to install it again I get an error and can't continue. Can't unistall either so I found a tool supplied by Microsoft. It will remove all the components so that I can run the installation again.

Microsoft Visual Studio 2008 RC/RTM uninstall tool



Change CD-Key in Windows Server environment

By Nisse Pettersson at November 30, 2009 01:45
Filed Under: Technical
Share on Facebook

If you need to change your KEY for Windows 2008 server there is a nice way to do this.

   1. Open the command prompt and change working directory to System32 directory
   2. Type in slmgr.vbs -ckms (this clears and KMS entry you may have)
   3. Type slmgr.vbs -upk (this removes any product key installed)
   4. Type slmgr.vbs -ipk xxxxx-xxxxx-xxxxx-xxxxx-xxxxx (where the x's is the new product key you want to use )
   5. Type slmgr.vbs -ato (this activates the server)

 

To do the same thing in Windows 2003 server follow these instructions.

  • Click Start, and then click Run.
  • In the Open box, type Regedit, and then click OK.
  • In the left pane, locate and then click the following registry key:
    HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\Current Version\WPAEvents
  • In the right pane, right-click OOBETimer, and then click Modify.
  • Change at least one digit of this value to deactivate Windows.
  • Click Start, and then click Run.
  • In the Open box, type the following command, and then click OK.
    %systemroot%\system32\oobe\msoobe.exe /a
    1. Click Yes, I want to telephone a customer service representative to activate Windows, and then click Next.
    2. Click Change Product key.
    3. Type the new product key in the New key boxes, and then click Update. If you are returned to the previous window, click Remind me later, and then restart the computer.
    4. Repeat steps 6 and 7 to verify that Windows is activated. You receive the following message:Windows is already activated. Click OK to exit.
    5. Click OK.
    6. Install SP1 for Windows XP.

    If you cannot restart Windows after you install SP1, press F8 when you restart the computer, select Last Known Good Configuration, and then repeat this procedure.

     



  • Spotify for Symbian phones

    By Nisse Pettersson at November 23, 2009 00:55
    Filed Under: Technical
    Share on Facebook

    I've just installed Spotify on my Nokia E75 and I like it. Been waiting a while for the Symbian version but now it's here. I listen to spotify every day on my computer so this is a nice application.

    Go get it here http://www.spotify.com/en/mobile/symbian/

    EDIT: After about 3hrs of use I feel that i would like to be able to change tracks with the hands free. I'm just able to adjust the volume.