Archive

Posts Tagged ‘debian’

Easy Backup Data Unix-Like

March 14th, 2010 Albertux No comments

Easy Backup Data Unix-Like

Some examples tested on Debian / Ubuntu

# Include .hidden_files (.svn/.git/etc...)
# copy dir on localhost
cp -a $SOME_PATH  $NEW_PATH
 
# apt-get install smbfs smbclient
# Samba remote to local
smbclient "//SOME_PLACE/SHARED FOLDER" -U $USER $PASS -c \
"cd \"$SOME_PATH\"; lcd \"$NEW_PATH\"; prompt; recurse; mget *; quit"
 
# wget -c "http://ossw.ibcl.at/FTPSync/ftpsync-latest.tar.bz2"
# User and Password on .netrc (chmod 600) [http://www.mavetju.org/unix/netrc.php]
# FTP remote to local
ftpsync -gv ftpserver=someserver.com  BackupWWW/ ftpdir=/www/
 
# SSH Copy File
scp $SOME_FILE $USER@$REMOTE:$SOME_PATH
# SSH Copy Dir
scp -r $SOME_PATH $USER@$REMOTE:$SOME_PATH
 
# apt-get install rsync
# Sync directories
rsync -v -u -a --delete --stats $SOME_PATH $BACKUP_PATH
 
# Backup System:
nc -lp $HOST > backup.tar.gz
tar cf - $DIR  | gzip  | nc -w 1 $HOST $PORT
 
# Clone disk to other disk (same host)
dd if=/dev/sdX of=$OUTPUT # (OUTPUT could be /dev/sdY or /some/path/disk.img)
 
# Clonning Hard Drive (other host)
nc -l -p $PORT | dd of=/dev/sda
dd if=/dev/sda | nc $HOST $PORT
 
# Date
NOW=`date +%h-%d-%Y-%H%M%S`
 
# Compress (z = gzip or j = bzip2)
tar cvzf $BACKUP_FILE-$NOW.tar.gz $SOME_PATH
 
# MySQL
mysqldump $DB -u $USER --password=$PASS | gzip -c > $DB-$NOW.sql.gz
# SQLite
echo '.dump' | sqlite3 $DB | gzip -c >$DB-$NOW.sql.gz
# PostgreSQL
# .pgpass (chmod 600)
pg_dump $DB | gzip -c > $DB-$NOW.sql.gz

Using crontab to run your backup(s) script(s)

Other stuff:

Amanda is a backup system that allows the administrator to set up a single master backup server to back up multiple hosts over network to tape drives/changers or disks or optical media.

DRBD refers to block devices designed as a building block to form high availability (HA) clusters. This is done by mirroring a whole block device via an assigned network. DRBD can be understood as network based raid-1.

Control Version Systems:
Subversion
Mercurial
Git

Are useful when you have different versions or configurations files.

Google Chrome OS

November 20th, 2009 Albertux No comments

Google Chrome OS

Google Chrome OS:

uname -a

Linux localhost 2.6.30-chromeos-intel-menlow #1 SMP Fri Nov 20 02:53:44 UTC 2009 i686 GNU/Linux

cat /etc/debian_version

squeeze/sid

dpkg -l

OUTPUT

lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 9.10 (development branch)
Release: 9.10
Codename: karmic

So full name:

Google Chrome OS (Cromium OS) – Ubuntu 9.10 Karmic Koala – Debian squeeze/sid 6.0 – Gnu/Linux

JSON File with Google Chrome settings:

/home/chronos/[user@gmail.com]/.config/google-chrome/Local State

Links:

Build Chromium OS

Download Google Chrome OS Virtual Machine (VMware and VirtualBox)

  • Categories: multimedia, unix/linux, web Tags: , , , ,

    Debian squeeze/sid

    October 8th, 2009 Albertux 3 comments

    Debian squeeze/sid

    I installed Debian Lenny on my notebook, but i want to test squeeze so I do this:

    # as root
    sed -i 's/lenny/squeeze/g' /etc/apt/sources.list
    aptitude update
    aptitude install apt dpkg aptitude
    aptitude full-upgrade
    # after reboot
    upgrade-from-grub-legacy # to use grub2

    I experimented some issues with dependencies but everything now is ok.

    Categories: unix/linux Tags:

    USB Scan Antivirus

    July 14th, 2009 Albertux No comments

    USB Scan Antivirus

    I made this script to clean USB Drives:

    usbscan.sh:

    #!/bin/bash
    # Author: Albertux (Alberto Isaac Ayala Esquivias)
    # Email: <albertoi7@gmail.com>
    # Web: http://www.AyalaSoft.com
    #
    # First install clamav: sudo apt-get install clamav
    # copy usbcan.desktop on /home/$USER/Desktop
    # copy usbscan on /home/$USER/bin/
    #
    # This script tested on Debian or Ubuntu
     
    USB="sdb1" # check first using mount command or cat /etc/mtab
     
    IFS=$'\t\n'
    LIGHT_RED="\033[1;31m"
    LIGHT_GREEN="\033[1;32m"
    LIGHT_BLUE="\033[1;34m"
    YELLOW="\033[1;33m"
    NORMAL="\033[0m"
     
    echo -e "${LIGHT_GREEN}"
    echo "#   #  #### ####       ####  ####  ###  #   #"
    echo "#   # #     #   #     #     #     #   # ##  #"
    echo "#   #  ###  ####   #   ###  #     ##### # # #"
    echo "#   #     # #   #         # #     #   # #  ##"
    echo " ###  ####  ####      ####   #### #   # #   #"
    echo -e "${NORMAL}"
    echo -n "Inserte el USB y precione [Enter]"
    read
    sleep 5
     
    USB_TMP=`cat /etc/mtab | grep $USB  | awk '{print $2}'`
    USB_PATH=`echo $USB_TMP | sed -e 's/\\\040/ /g'`
     
    if [ -z $USB_PATH ];
    then
    	echo -en "\n${LIGHT_RED}AVIZO!${NORMAL} \"USB no detectado, precione [Enter]\""
    	read
    	exit
    fi
     
    echo -e "\nUSB localizado en [${LIGHT_BLUE}$USB_PATH${NORMAL}]"
    echo -e "\n${YELLOW}AVIZO!${NORMAL} \"No desconecte el USB hasta que se le indique\"\n"
    clamscan --remove --infected --recursive $USB_PATH > usbscan.log 2> usbscan.err.log
    umount /dev/sdb1
    echo -en "\n${YELLOW}LISTO!${NORMAL} \"Puede desconectar el USB, precione [Enter]\""
    read

    usbscan.desktop:

    [Desktop Entry]
    Encoding=UTF-8
    Version=1.0
    Type=Application
    Terminal=true
    Icon[en_US]=gnome-panel-launcher
    Exec=/home/aayala/usbscan.sh
    Name[en_US]=USB SCAN
    Name=Antivirus
    Icon=/home/aayala/bin/.virus.png

    eicar.com (virus test file):

    X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*

    virus.png:

    Notes:
    The scan is slow but efective

    Categories: security, windows Tags: , , ,

    Debian Lenny Intel(R) Pro/Wireless

    May 12th, 2009 Albertux 2 comments

    Debian Lenny Intel(R) Pro/Wireless

    After you install Debian using netInstall using wire interface you can install the firmware that support your wireless interface this is example script:

    #!/bin/bash
    # Debian Lenny Wireless script for Intel(R) Pro/Wireless 4954 or 3945
    # Author: Albertux (Alberto Isaac Ayala Esquivias)
    # Mail: <albertoi7@gmail.com>
    # Web: http://Albertux.AyalaSoft.com
     
    if [[ $EUID -ne 0 ]]; then
      echo "You must be a root user" 2>&1
      exit 1
    fi
     
    for m in iwl4965 iwl3945
    do
      model=$(echo `dmesg  | grep $m | awk ' { print $3 }' |  wc -l`)
      if [ $model -ne 0 ]; then
        model=$m
        break;
      fi
    done
     
    if [ "$model" != "$m" ]; then
      echo -e "\e[01;33mWARNING!"
      echo -e "\e[01;33mDoesn't have Intel(R) PRO/Wireless 4965 or 3945 Models\e[00m"
      exit;
    else
      echo -e "\e[01;32mYou have Intel(R) PRO/Wireless $model\e[00m"
    fi
     
    firmware=$(echo `dpkg -l | grep firmware-iwlwifi | awk '{ print $1 }'`)
    mod=$(echo `lsmod  | awk '{ print $1 }'  | grep $model`)
     
    if [ "$firmware" != "ii" ]; then
      echo -e "Install firmware ..."
      apt-get install firmware-iwlwifi
    fi
     
    if [ "$model" != "$mod" ]; then
      echo -e "Install module ..."
      modprobe $model
    fi
    echo -e "\nname\t  description\n"
    iwconfig
    echo -n "Name of the interface with wireless extensions: "
    read iface
     
    ifconfig $iface up
    clear
    echo -e "Scanning Wireless ..."
    iwlist $iface scanning
     
    echo -n "essid: "
    read essid
     
    echo -n "Need Key (y/n): "
    if [ "$op" = "n" ]; then
      iwconfig $iface essid "$essid"
    else
      echo -n "key: "
      read key
      iwconfig $iface essid "$essid" key "$key"
    fi
     
    echo -n "Static IP? (y/n): "
    read op
     
    if [ "$op" = "n" ]; then
      dhclient $iface
    else
     echo -n "What ip you want: "
     read ip
     ifconfig $iface $ip
    fi
     
    echo -n "Gateway: "
    read gw
     
    route add default gw $gw $iface
    Categories: network, unix/linux Tags: , ,