Backup Data, Website and Mysql

Well, If it comes down to a simple Homenetwork - and a PC crash, normal situation is following: You're mostly dead in the water.
Why?
Because most ppl don't backup their data on a regular basis or do it wrong.
Actually, there are 3 kinds of pepole:
a) The person who doesn't backup
b) The person who *thinks* does a backup - but does it wrong
c) The person who does a backup and stops after a while because he is too lazy... and experiences a crash...

Well, I myself count am Type c) - I did backup for example my E-Mails in Outlook Express - but stopped after a while, and a year later I got a really big crash.
So, today, I use Thunderbird ( 😉 Thats plus, ain't it? ) and I do backup at least weekly - or on an "ohmygodthatcouldturnoutbadithinkishoulddoanbackupNOW!" basis.
And because I got three computers already in my network which does need backup and updates on an daily basis, I built myself an little nice Dual Atom based Server.

But thats another story.

So, here the best tools for backing up your data and my personal notices to that, have fun and take care!

Databackup:
Rsync
Rsync is the most widely used backup tool in the unix world. And it does also come in an windows flavor!
The best thing about rsync? It does only transfer file changes, and not a stupid "folder-to-folder" copy.
Rsync is a client-server based tool. So the best idea is to install the server on an "real" server with some nice RAID5 System,
and let the client do the work on for example your windows xp machine. Oh, by the way: There is no problem in having
an unix/linux rsync server and an windows xp client. Works out all the way. But thats not the only thing you can do:
You can also install the server and client on the same pc and use it to make backups from your usb stick to your harddrive (for example).
Rsync: http://samba.anu.edu.au/rsync/
DeltaCopy (Windows Rsync with Gui): http://www.aboutmyip.com/AboutMyXApp/DeltaCopy.jsp

FTP / Webbackup:
FtpSync
If you're the poor kind of person which does host its Website with an "you-get-no-shell" hoster like I am, you need to backup your Website in another fashion as rsync:
FTPSync seems to be the perfect solution because it only transfers changed files, it does reduces the amount of "for backup used bandwith" by a big deal. (I myself host about 600 mb now on files, pictures and other things - and this little guy is really an helper) FTPSync does run on Windows 2000 and above. It can use scripts / ini Files which allow FTP-To-FTP Sync, as well as FTP-To-File Sync. So, also useful if you build up your Website on your Homeserver and want to commit the changes.
FtpSync: http://www.cyberkiko.com/category/FTPSync.aspx

Mysql Backup:
Mysqldumper and phpMyBackupPro
As already mentioned, no shell access is a hard thing for an Website Administrator. Especially when it comes to Mysql Backups - called Dumps. Well, yes you can use phpMyAdmin to Dump these Files - but there is a maximum php execution time which does sometimes corrupts your backup - in case the database has grown too big.
In this case there are two tools which will help you: Mysqldumper and phpMyBackupPro. First: They both do backup and restore. That said, what are the main differences? a) Mysqldumper has the advatage of using multiple mysql logins, as given away by most hosters (you get for example 3 databases, and everyone got another login name and password - its more secure and you can use it and share it with other projects). b) phpMyBackupPro is easier to configure in terms of cronjobs, so automatic backups as Mysqldumper. Which of these tools you use is your choice, and depends on the features you need.
Mysqldumper: http://www.mysqldumper.de/
phpMyBackupPro: http://www.phpmybackuppro.net/

Tipp: You should use the Mysql Backup Tools in conjunction with FTPSync to Backup your complete account.

[Eee901] Create an Backtrack 3 Eee901 Usb Stick

There are dozend Situations in which Backtrack 3 comes in handy.
Backtrack 3 is an special Linux Suite of Security Auditing Tools which allow i.e. WEP Cracking, Network Security Checking, Sniffing, and so on.
To make this nice Suite a bit more portable, we will put it onto an Usb Stick and customize it with Eee901 Drivers, persistent Changes and Nessus 4!

Download:
Backtrack 3 USB Version: http://www.remote-exploit.org/backtrack_download.html
unetbootin Windows: http://unetbootin.sourceforge.net
Partiton Tool, like partedmagic: http://partedmagic.com
Eee901 Pack: 901_net_gfx.lzm (you'll find it in google)
Nessus 4.0.2: http://www.nessus.org/download/
( We need the 4.0.2 as Nessus-4.0.2-linux-generic32.tar.gz and the Graphical Linux Interface for nessusd NessusClient-4.0.2-es4.i386.rpm )
And you should help yourself to an free personal key under http://www.nessus.org/plugins/?view=register-info

Preparation:
First thing is you need to prepare the Usb Stick. For Backtrack 3, an 2 GB Stick should be ok. For Backtrack 4, you would need an 4 GB Stick at least.
1) Get your stick and partedmagic CD
2) Plug it in and boot to partedmagic
3) Create with the Partitioneditor 2 Partitions
- 1) fat32, 900mb
- 2) ext2, 1100mb
-> write down if your usb stick is sda1, sdb1, or what.
4) Reboot - again to partedmagic
Now create an folder called changes to the second partition.
Should look somehow like this (not nice, but should work if you're on sda2...):

mount /dev/sda2 /mnt
cd /mnt
mkdir changes
cd /
umount /mnt

5) Done, boot to Windows

Installation of Backtrack 3:
1) Start unetbootin
2) Choose Disk Image, ISO and as file the Backtrack3 USB
3) Check wheter the destination drive is correct (your usb stick, fat32 partition) - CHECK TWICE! And Error would kill your System!
4) Press Ok and wait until its done, do NOT reboot
5) Copy 901_net_gfx.lzm to your usb stick, folder BT3\optional
6) Open syslinux.cfg in boot\syslinux\ and add following lines, which will be your new menu entrys for booting from the usb stick - with eee901 drivers.

label eee901save
menu label BT3 Graphics mode (Eee901) - Save Changes
kernel /boot/vmlinuz
append vga=785 initrd=/boot/initrd.gz ramdisk_size=6666 root=/dev/ram0 rw load=901_net_gfx autoexec=kdm changes=/dev/sda2

label eee901
menu label BT3 Graphics mode (Eee901)
kernel /boot/vmlinuz
append vga=785 initrd=/boot/initrd.gz ramdisk_size=6666 root=/dev/ram0 rw load=901_net_gfx autoexec=kdm

WARNING! changes=/dev/sda2 MUST be changed to what you saw on the partition - and maybe you still need to try it out.
2 means second partiton and thats right - ext2 partition. This changes tells Backtrack where it should save the changes you make while working in it.
the changes could be sda2 or sdb2 or sdc2. But mostly its sda2.

Save after you're done

7) Open cmd and access your usb stick, cd to boot\syslinux\ and execute this:
syslinux.exe -ma -d \boot\syslinux H: (H: should be your usb drive letter... will be different!)
This will write the bootmanager to the usb stick with the settings you entered in 6).
After changing for example the changes line there, you will need to repeat this again, also.

8) You're done. Boot from the stick, it should work.

Insallation of Nessus 4:
Nessus is an auditing tool which is really strong - but is not complete opensource - so you need to install it manually.
Boot onto your Backtrack 3...

Install NessusServer
Nessus-4.0.2-linux-generic32.tar.gz
gunzip Nessus-4.0.2-linux-generic32.tar.gz
tar -xvf Nessus-4.0.2-linux-generic32.tar
cd Nessus-4.0.2
install.sh

Follow the install instructions

/opt/nessus/sbin/nessus-mkcert
/opt/nessus/sbin/nessus-adduser
cd /opt/nessus/etc/nessus
nessus-fetch --register XXX-YYY-ZZZ-VVV (Serial you obtained)

Launch the Server:
/opt/nessus/sbin/nessus-service -D

Install NessusClient
NessusClient-4.0.2-es4.i386.rpm
rpm2tgz NessusClient-4.0.2-es4.i386.rpm
pkgtool (Select NessusClient-4.0.2-es4.i386)
cp /usr/lib/libssl.so.0.9.8 /lib
cp /usr/lib/libcrypto.so.0.9.8 /lib
cd /lib
ln -s libcrypto.so.0.9.8 libcrypto.so.4
ln -s libssl.so.0.9.8 libssl.so.4

Launch the Client:
/opt/nessus/bin/NessusClient

Nessus Install taken from: http://forums.remote-exploit.org/backtrack3-howtos/22031-backtrack3-nessus-4-0-install.html
Rest from Remote Exploit and others / google

[Vista] How To Disable Network Auto Tuning and fix Connectivity Problems

Autotuning dynamically changes the TCP Window Size - which often causes errors as loss of network connectivity, firewall problems, and so on.

To show the status of this autotuning, you should check it with admin rights under cmd with this command: netsh interface tcp show global
To disable use: netsh interface tcp set global autotuning=disabled
To reenable use: netsh interface tcp set global autotuning=normal

Another important thing concerning wireless problems - you should install Service Pack 2, as it does contain an bunch of hotfixes and other important stuff.

Toshiba Satellite P300D-211 (PSPDCE-02KOOWGR) Wireless Problems

The Satellite \ Satellite Pro P300 \ P300D Series suffers from Problems with Wireless Connectivity.
To solve these problems you need to upgrade to at least Bios Version 3.00 (recent is 3.10).
For XP and Vista64, that should already fix it.
For Vista32, you need to upgrade the Wireless Lan Drivers as well.
But I would recommend upgrading it also on x64 Systems.

(disabling autotuning for networking and installing sp2 should help as well!)

Reset Password on Linux

1. Boot with Knoppix
2. mount /dev/sda1 /mnt
3. vi /etc/shaodw
4. i
5. kill the string between the first and second :...
for example: user:$1$pM8HYEMB$Cx0yiRM4pj2Ty4lFBWuy4.:12038:0:99999:7::: becomes:
user::12038:0:99999:7:::
6. ESC :w Enter
7. cd /
8. umount /mnt
9. reboot
10. login with user and just press enter on password.
11. enter passwd and change the password.
12. you're done!

c3560 Cheat

Hostname:
hostname test

Image Upgrade:
del /r /f flash:c3560-ipbase-mz.122-35.SE5
copy tftp://192.168.2.1/images/c3560-ipbasek9-mz.122-46.SE.bin flash:

del - File
rm - Folder

Boot with other Image:
boot system c3560-advipservicesk9-mz.122-46.SE.bin

Portfast (on dhcpd Problems):
spanning-tree portfast

Switchport with Vlan 10:
interface FastEthernet0/1
switchport access vlan 10
switchport mode access
description nativ
macro description NATIV
spanning-tree portfast

Description Vlan 10:
vlan 10 name testvlan

Trunkport:
interface GigabitEthernet0/1
switchport trunk encapsulation dot1q
switchport mode trunk
ip dhcp snooping trust

DHCP Snooping:
Global Activate:
ip dhcp snooping vlan 1-4094
no ip dhcp snooping information option
ip dhcp snooping

Allow DHCP on Port:
ip dhcp snooping trust

ESXi Trunking:
ip dhcp snooping vlan 1-4094
no ip dhcp snooping information option
ip dhcp snooping

these are the vlans, one main, one “test” for the vm
vlan 1
name main
vlan 999
name test

normal client port
interface FastEthernet0/1
switchport access vlan 1
spanning-tree portfast

vm client port which does access vlan 999
interface FastEthernet0/3
switchport access vlan 999
spanning-tree portfast

vm server port, which does access normal vlan 1, and does trunk the rest
” ip dhcp snooping trust” means, that this port is allowed to answer dhcp requests
interface FastEthernet0/7
switchport trunk encapsulation dot1q
switchport trunk native vlan 1
switchport trunk allowed vlan 1,999
switchport mode trunk
ip dhcp snooping trust
end

Routing with c3560-advipservicesk9-mz.122-46.SE.bin:
( Every Net needs a own Vlan! )
( The Vlan Ip is the Gateway )

ip routing

interface FastEthernet0/1
switchport access vlan 2
switchport mode access

interface FastEthernet0/8
switchport access vlan 3
switchport mode access

interface Vlan2
ip address 134.96.10.1 255.255.255.0

interface Vlan3
ip address 192.168.2.1 255.255.255.0

c3560 Routing with Advanced IP Services

Problem: You got serval networks, you got an c3560 but no Router.
Solution: Get an c65e VSS
Following Problem: Insufficient Money, Power, Space,....
Solution: Get your c3560 to route these Networks with an Advanced IP Services Firmware
YOU DO NEED AN "advipservices" FIRMWARE ON YOUR c3560!

Assumption:
On f0/1 PC with 134.96.10.2 -> We want the Gateway to be 134.96.10.1
On f0/8 PC with 192.168.2.2 -> We want the Gateway to be 192.168.2.1

How to:
Easy Idea - for an normal routing process you need an Interface in the "to be routed" net.
And there for the Solution lies in the usage of vlans.
Every port that uses one net is bound to the vlan of that net.
Every net get its own vlan.
Every vlan gets an ip (the gateway ip thats entered into the pcs of this net).
Activate routing.
Done.

Configuration:

interface FastEthernet0/1
switchport access vlan 2
switchport mode access

interface FastEthernet0/8
switchport access vlan 3
switchport mode access

interface Vlan2
ip address 134.96.10.1 255.255.255.0

interface Vlan3
ip address 192.168.2.1 255.255.255.0

ip routing

SCP with Plain Password

My altered Version:

Call it with ./scp_bkp.sh User Password BKPPath ServerIP

#!/usr/bin/expect -f

set USER [lrange $argv 0 0]
set PW [lrange $argv 1 1]
set BKPPath [lrange $argv 2 2]
set IP [lrange $argv 3 3]

# 1 User, 2 PW, 3 BkpPath, 4 IP

# trick to pass in command-line args to spawn
#eval spawn scp $argv
eval spawn scp $USER@$IP:/bootbank/state.tgz $BKPPath

expect "password: $"
send "$PW\n"

# wait for regular shell prompt before quitting
# probably a better way using 'wait'
expect "$ $"

Orginally taken from: http://tiebing.blogspot.com/2009/01/scp-with-automatic-password-input.html