Sonntag, 19. Juni 2011

Clonezilla: Automatisches Backup auf ext. USB Festplatte

CloneZilla BootCD/ISO anpassen um ein Automatisches Backup
auf eine USB-Festplatte machen zu können.

Downloaden der ISO z.B. clonezilla-live-20110530-natty.iso
http://clonezilla.org/downloads/alternative/iso-zip-files.php

Öffnen der ISO-Datei: clonezilla-live-20110530-natty.iso mit ISOMaster (http://www.littlesvr.ca/isomaster/)

1. Erstellen eines Verzeichnises "custom" in der ROOT des ISOs

2. Erstellen des Scripts "ocs-clientname.sh" für das Backup
in diesem Beispiel wird eine ext. USB-Festplatte
mittels uuid gemountet und nach /home/partimag gemountet

Das Script erzeuget ein Verzeichnis clientname_HHMMSSTTMMJJJJ in das das Backup geschrieben wird.


Script für /dev/sda

##!/bin/bash
# Author: Steven Shiau
# License: GPL
# When this script is ready, you can run
# /opt/drbl/sbin/ocs-iso -g en -k NONE -s -m ./custom-ocs
# to create the iso file for CD/DVD. or
# /opt/drbl/sbin/ocs-live-dev -g en -k NONE -s -c -m ./custom-ocs
# to create the zip file for USB flash drive.
# Begin of the scripts:
# Load DRBL setting and functions
if [ ! -f "/opt/drbl/sbin/drbl-conf-functions" ]; then
echo "Unable to find /opt/drbl/sbin/drbl-conf-functions! Program terminated!"
exit 1
fi

. /opt/drbl/sbin/drbl-conf-functions
. /opt/drbl/sbin/ocs-functions

# load the setting for clonezilla live.
[ -e /etc/ocs/ocs-live.conf ] && . /etc/ocs/ocs-live.conf

# Load language files. For English, use "en_US.UTF-8". For Traditional Chinese, use "zh_TW.UTF-8"
ask_and_load_lang_set en_US.UTF-8

# The above is almost necessary, it is recommended to include them in your own custom-ocs.
# From here, you can write your own scripts.
echo "#########################################################################################"
echo "# 1. Configure network"
#dhclient
echo "#########################################################################################"
echo "# 2. Mount the clonezilla image home"

mkdir /home/partimag
mount /dev/disk/by-uuid/9a467114-d745-4b53-b1ab-f70ca1918d0d /home/partimag

echo "#######################################after mounting, now showing mounts###########"
mount
echo "#########################################################################################"
echo "# 3. backing up sda"
/opt/drbl/sbin/ocs-sr -b -q -j2 -z1 -i 0 -p reboot savedisk "clientname_`date +%H%M%S_%d%m%Y`" "sda"
echo "#########################################################################################"



Script für /dev/hda

##!/bin/bash
# Author: Steven Shiau
# License: GPL
# When this script is ready, you can run
# /opt/drbl/sbin/ocs-iso -g en -k NONE -s -m ./custom-ocs
# to create the iso file for CD/DVD. or
# /opt/drbl/sbin/ocs-live-dev -g en -k NONE -s -c -m ./custom-ocs
# to create the zip file for USB flash drive.
# Begin of the scripts:
# Load DRBL setting and functions
if [ ! -f "/opt/drbl/sbin/drbl-conf-functions" ]; then
echo "Unable to find /opt/drbl/sbin/drbl-conf-functions! Program terminated!"
exit 1
fi

. /opt/drbl/sbin/drbl-conf-functions
. /opt/drbl/sbin/ocs-functions

# load the setting for clonezilla live.
[ -e /etc/ocs/ocs-live.conf ] && . /etc/ocs/ocs-live.conf

# Load language files. For English, use "en_US.UTF-8". For Traditional Chinese, use "zh_TW.UTF-8"
ask_and_load_lang_set en_US.UTF-8

# The above is almost necessary, it is recommended to include them in your own custom-ocs.
# From here, you can write your own scripts.
echo "#########################################################################################"
echo "# 1. Configure network"
#dhclient
echo "#########################################################################################"
echo "# 2. Mount the clonezilla image home"

mkdir /home/partimag
mount /dev/disk/by-uuid/9a467114-d745-4b53-b1ab-f70ca1918d0d /home/partimag

echo "#######################################after mounting, now showing mounts###########"
mount
echo "#########################################################################################"
echo "# 3. backing up hda"
/opt/drbl/sbin/ocs-sr -b -q -j2 -z1 -i 0 -p reboot savedisk "clientname_`date +%H%M%S_%d%m%Y`" "hda"
echo "#########################################################################################"



Wichtig ist das das Script: "ocs-clientname.sh" mittels chmod 755 ausführbar gemacht wird.
oder per ISOMaster mit change Permissions rwx-r-x-r-x


Wie findet man die uuid einer Partiton herraus ?

Booten mit der CloneZilla ISO/CD

Enter Commandline

$ sudo su -

# tune2fs -l /dev/sdbX | grep "Filesystem UUID:"

z.B.

# tune2fs -l /dev/sdb1 | grep "Filesystem UUID:"


3. Anpassung / Erstellung der Datei: isolinux/isolinux.cfg

# Since no network setting in the squashfs image, therefore if ip=frommedia, the network is disabled. That's what we want.
label Clonezilla clientname
# MENU HIDE
MENU LABEL Autobackup CLIENTNAME
# MENU PASSWD
kernel /live/vmlinuz
append initrd=/live/initrd.img boot=live hostname=natty config quiet noswap nolocales edd=on nomodeset ocs_live_run="/live/image/custom/ocs-clientname.sh" ocs_live_extra_param="" ocs_live_keymap="/usr/share/keymaps/i386/qwertz/de-latin1-nodeadkeys.kmap.gz" ocs_live_batch="yes" ocs_lang="en_US.UTF-8" video=uvesafb:mode_option=800x600-16 ip=frommedia
nosplash
TEXT HELP
* Clonezilla live version: 20110530-natty. (C) 2003-2011, NCHC, Taiwan
* Disclaimer: Clonezilla comes with ABSOLUTELY NO WARRANTY
ENDTEXT


4. die Orginale Datei: /isolinux/isolinux.cfg entfernen
und die selbst erstellte Datei einfügen

5. Speichern als neues ISO
ggf. auf CD-ROM brennen

Samstag, 29. Januar 2011

screen - ein schönes Tool

screen neue Session beginnen
Ctrl-a Ctrl-\ Quit screen
Ctrl-a d Detach but keep shell window open
screen –r Session nach Abbruch oder detach fortsetzen
Ctrl-a [ Start copy mode (friert Bildschirm ein)
Cursortasten, h,j,k,l Navigation im Copy mode
SPACE Markiert Anfangs- und Endpunkt im Copy mode
Ctrl-a ] Paste copied text

Daten auf myDrive.ch verschlüsselt speichern

Getestet mit Ubuntu 10.10 (64bit)


0. Nötige Pakete installieren

1. MyDrive.ch account anlegen

2. Verschlüsselten Container erzeugen

3. Upload des Containers auf MyDrive

4. Mounten des Containters

5. Spass haben




0. sudo apt-get install cryptsetup davfs2

sudo mkdir /media/mydrive

sudo mkdir /media/cryptfs

1. per Browser auf http://www.mydrive.ch gehen
und einen Kostenloses Account anlegen

2. dd if=/dev/zero of=meins bs=1M count=256
(hier wird eine 256 MB grosse Datei erstellt mit dem Namen: meins)

sudo losetup /dev/loop0 meins

dd if=/dev/urandom of=/dev/loop0 bs=1M count=2

cryptsetup luksFormat -c aes-cbc-essiv:sha256 -s 256 -y /dev/loop

(hier Informieren was das beste Format für die Verschlüsselung ist)

cryptsetup luksOpen /dev/loop0

z.B.

sudo cryptsetup luksOpen /dev/loop0 myDrive

sudo mkfs.ext4 /dev/mapper/myDrive

sudo cryptsetup luksClose /dev/mapper/myDrive

sudo losetup -d /dev/loop0


3. Anmelden auf MyDrive.ch
die Datei: meins hochladen



4. Zuerst muss man myDrive.ch mounten

sudo mount.davfs https://webdav.mydrive.ch /media/mydrive

sudo losetup /dev/loop0 /media/mydrive/meins

sudo cryptsetup luksOpen /dev/loop0 myDrive

sudo mount /dev/mapper/myDrive /media/cryptfs



Abhängen des Filesystems:

sync

sudo umount /dev/mapper/myDrive

sudo cryptsetup luksClose /dev/mapper/myDrive

sudo losetup -d /dev/loop0


umount /media/mydrive

(Auch das unmounten kann lange dauern, je nach Internetverbindung)

Donnerstag, 14. Oktober 2010

sendmail mailq leeren

Sendmail - mail queue abarbeiten

sendmail -q -v

AIX Infos

Unter AIX findet man mot folgendem Befehl herraus welche MTU die Karte hat

# lsattr -E -l en0

MAC-Addressen anzeigen lassen

# netstat -ia

Anzeigen welche Packete unter hier im beispiel: TL 5 von AIX 6.1 liegen

# oslevel -r -l 6100-05


Bootfähiges Image einer AIX / VIO erstellen

das file name.vol1 in name.iso umbenennen

mkcd -V rootvg -L -S

-L DVD Images erstellen
-S DVD-Images nicht löschen
-V welche volumegroup


Hardwareinfos

# lscfg -vl fcsX

z.B:

# lscfg -vl fcs1

Microcode

# lsmcode -d cdX

z.B.

# lsmcode -d cd0




bootinfo -y Hardware

bootinfo -K Kernel

Netzwerkarten nach Clone nicht mehr eth0 - was tun ?

Wenn man einen Clone z.B. mit CloneZilla von einer Linux-Maschine macht.
Kommt es vor, dass die Netzwerkarte(n) nicht mehr eth0 (/ eth1) sind sondern eth2 (/ eth3)

Dies lässt sich beheben in dem man in folgender Datei:

/etc/udev/rules.d/??-persistent-net.rules

Die Einträge anpasst, dann hat man wieder z.B. eine eth0 in dem geclonten System.

Automatisches Backup auf eine Netzwerkfreigabe mit CloneZilla

0. Laden des Tools von http://www.pendrivelinux.com/boot-multiple-iso-from-usb-multiboot-usb/

1. Herunterladen der CloneZilla ISO unter: http://clonezilla.org/ (Alternative Version)

2. Herunterladen der Memtest ISO von http://www.memtest.org/

3. USB-Stick einstecken, Tool (MultiBootISOs-X.X.X.X.exe) unter Windows starten
Formatieren des Sticks auswählen und die Memtest Datei.
Und das Programm laufen lassen.

4. ggf. die CloneZilla ISO Datei entpacken mit z.B: 7zip (http://www.7-zip.org/)
in das Verzeichnis clonezilla auf dem USB-Stick

5. anpassen der Datei: menu.lst auf folgenden Inhalt


default 0

timeout 5

color NORMAL HIGHLIGHT HELPTEXT HEADING

splashimage=/splash.xpm.gz

foreground=FFFFFF

background=000000





title Boot Clonezilla (AUTOBACKUP /dev/sda)

find --set-root /clonezilla/live/initrd1.img

kernel /clonezilla/live/vmlinuz1 boot=live live-config noswap nolocales edd=on nomodeset ocs_live_run="/live/image/clonezilla/custom-ocs" ocs_live_extra_param="" ocs_live_keymap="/usr/share/keymaps/i386/qwertz/de-latin1-nodeadkeys.kmap.gz" ocs_live_batch="yes" ocs_lang="en_US.UTF-8" vga=791 nolocales live-media-path=/clonezilla/live

initrd /clonezilla/live/initrd1.img





title Boot Clonezilla (AUTOBACKUP /dev/hda)

find --set-root /clonezilla/live/initrd1.img

kernel /clonezilla/live/vmlinuz1 boot=live live-config noswap nolocales edd=on nomodeset ocs_live_run="/live/image/clonezilla/custom-ocs-hda" ocs_live_extra_param="" ocs_live_keymap="/usr/share/keymaps/i386/qwertz/de-latin1-nodeadkeys.kmap.gz" ocs_live_batch="yes" ocs_lang="en_US.UTF-8" vga=791 nolocales live-media-path=/clonezilla/live

initrd /clonezilla/live/initrd1.img





title Boot Clonezilla

find --set-root /clonezilla/live/initrd1.img

kernel /clonezilla/live/vmlinuz1 boot=live live-config noswap nolocales edd=on nomodeset ocs_live_run='ocs-live-general' ocs_live_extra_param='' ocs_live_keymap='de' ocs_live_batch='no' ocs_lang='en' vga=788 ip=frommedia nosplash live-media-path=/clonezilla/live toram=filesystem.squashfs

initrd /clonezilla/live/initrd1.img





# Suggested by Erhan Sohail

title Boot First Hard Drive (HDD)

map (hd0) (hd1)

map (hd1) (hd0)

map --hook

chainloader (hd0)+1

rootnoverify (hd0)



title Restart

reboot



title Shutdown

halt



6. erstellen der 2 Dateien: custom-ocs und custom-ocs-hda im Verzeichnis clonezilla auf dem USB-Stick

mit folgendem Inhalt:

#!/bin/bash

# Author: Steven Shiau

# License: GPL

# When this script is ready, you can run

# /opt/drbl/sbin/ocs-iso -g en -k NONE -s -m ./custom-ocs

# to create the iso file for CD/DVD. or

# /opt/drbl/sbin/ocs-live-dev -g en -k NONE -s -c -m ./custom-ocs

# to create the zip file for USB flash drive.

# Begin of the scripts:

# Load DRBL setting and functions

if [ ! -f "/opt/drbl/sbin/drbl-conf-functions" ]; then

echo "Unable to find /opt/drbl/sbin/drbl-conf-functions! Program terminated!"

exit 1

fi

. /opt/drbl/sbin/drbl-conf-functions

. /opt/drbl/sbin/ocs-functions

# load the setting for clonezilla live.

[ -e /etc/ocs/ocs-live.conf ] && . /etc/ocs/ocs-live.conf

# Load language files. For English, use "en_US.UTF-8". For Traditional Chinese, use "zh_TW.UTF-8"

ask_and_load_lang_set en_US.UTF-8

# The above is almost necessary, it is recommended to include them in your own custom-ocs.

# From here, you can write your own scripts.

echo "#########################################################################################"

echo "# 1. Configure network"

dhclient

echo "#########################################################################################"

echo "# 2. Mount the clonezilla image home"

mkdir /home/partimag

mount -t cifs -o username=USERNAME,password=PASSWORD //SERVERNAME/SHARE /home/partimag

echo "#######################################after mounting, now showing mounts###########"

mount

echo "#########################################################################################"

echo "# 3. backing up sda"

/opt/drbl/sbin/ocs-sr -b -q -j2 -z1 -i 0 -p reboot savedisk "CLIENTNAME_`date +%H%M%S_%d%m%Y`" "sda"

echo "#########################################################################################"



bzw. die Zeile

/opt/drbl/sbin/ocs-sr -b -q -j2 -z1 -i 0 -p reboot savedisk "CLIENTNAME_`date +%H%M%S_%d%m%Y`" "hda"

in der Datei: custom-ocs-hda anpassen


ACHTUNG: es müssen folgende Zeilen angepasst werden:

mount -t cifs -o username=USERNAME,password=PASSWORD //SERVERNAME/SHARE /home/partimag

ersetzen in z.B.

mount -t cifs -o username=backup,password=backup4client //10.1.1.250/backup /home/partimag


/opt/drbl/sbin/ocs-sr -b -q -j2 -z1 -i 0 -p reboot savedisk "CLIENTNAME_`date +%H%M%S_%d%m%Y`" "sda"

ersetzen in z.B.

/opt/drbl/sbin/ocs-sr -b -q -j2 -z1 -i 0 -p reboot savedisk "CLI01_`date +%H%M%S_%d%m%Y`" "sda"


Das wars....