Simple backup

7 posts / 0 new
Last post
djagga
Simple backup

E un script simplu pentru archiva un director


#!/bin/sh
# director de backup,sursa si tmp
BUPDIR=/backup/
SRCDIR=/var/www/html/
TMP=/tmp
# retine cite fisiere ?
KEEP=2
##############################
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/mysql/bin:/root:/etc
# current date
DATE=`date +"%h_%d_%Y"`
# filename
FILE="${BUPDIR}nume-fisier-${DATE}.tar.bz2"
# backup
tar -jcf $FILE $SRCDIR >/dev/null 2>&1
if [ `ls -1 $BUPDIR | wc -l` -gt $KEEP ]; then
i=
for each in `ls -1t $BUPDIR`; do
if [ $i -gt $KEEP ]; then
rm -f -- ${BUPDIR}/${each}
fi
let "i = i + 1"
done
fi

echo "done"
###############################

Patkos Csaba
E OK scriptul, foloseam si eu

E OK scriptul, foloseam si eu candva de mult din astea DAR ;) vezi ce stie "rdiff-backup" ( http://rdiff-backup.nongnu.org/ ), cred ca o sa-ti placa.

Csabi′s BLOG

Linux registered user # 457717

symbianflo
symbianflo's picture
numai ce am impachetat ptr

numai ce am impachetat ptr mib fwbackups
http://mib.pianetalinux.org/mib/quick/basic-rpms/mib-rpms/777-fwbackups-...
ia vezi ce stie ala .

io ramin al dd-ul meu , care nu l-as da pe nici un alt tool :p
faceti voi cu tools-uri si scripturi .....ghghghghgh
ascultati la mine
dd +testdisk+photorec si alceva ptr backup&recovery nu va trebuie .

@csaba

esti cam fixat cu : "....over a network........" :p
guru retelelor , vezi mai is si alte chestii in afara de retelistica :p ghghghghgh


http://www.mandrivausers.ro/ MRB aint no shit , :p Linux user number 507107 Nu dați banii pe prostii, puneți Linux pe PISI ![ARLUG]

Unix is user-friendly. It’s just very selective about who its friends are

mandi
mandi's picture
Arunca un ochi si pe rsync

dd e fain, daca vrei si MBR. Daca nu ai de gand sa strici MBR, rsync RULEZ, vorba rusului. Cam in genul 'rdiff-backup'. Mai ales ca azi spatiu' de stocare e relativ ieftin.
de ex., eu folosesc pt. / backup:
[code]su -
rsync -abv --delete --delete-excluded --exclude="/sys/**" --exclude="/proc/**" --exclude="/dev/**" --exclude="/home/" / /mnt/backup[/code] --exclude="/home/", daca e partitie separata. Merge inclus in cronjob.
Restore se poate face pe un sistem care nu ruleaza (de pe un live, de ex.), inversand sursa cu destinatia:
'rsync -av /mnt/backup/ ' ; la restore, atentie la ultimul [/] pt sursa (la mine ..backup/)
Avantaju' ar fi viteza. Bun si la defragmentat ext4 :)

Patkos Csaba
rdiff-backup de fapt se

rdiff-backup de fapt se foloseste de rsync sau se bazeaza pe el, doar ca ofera cateva optiuni specifice de backup mai faine decar rsync-ul chel ...

Csabi′s BLOG

Linux registered user # 457717

Patkos Csaba
Si daca tot vorbim de

Si daca tot vorbim de backup-uri, iata 2 articole interesante peste care am dat intamplator astazi:
http://blogs.techrepublic.com.com/opensource/?p=1421
http://www.ghacks.net/2010/04/13/luckybackup-linux-backup-made-easy/

Csabi′s BLOG

Linux registered user # 457717

Patkos Csaba
rdiff-backup script

Astazi am implementat un sistem de a salva tot ce este necesar din serverul de la servici catre un folder montat CIFS de pe un network storage Edimax NS-2502 (mai multe despre acest NAS veti gasi pe blogul meu in zilele urmatoare).

Nota: am observat ca rdiff-backup este destul de lenes ca atare, asa ca scriptul ruleaza pana in 10 procese de rdiff-backup si asa maximizez mai bine banda de transfer. Serverul pe care ruleaza este un IBM cu 2 procesoare Xeon quad-core.

#!/bin/bash

#backup homes
maxjobs=10
cjobs=0
find /home -maxdepth 1 -mindepth 1 -type d | while read i ; do
echo "Backing Up: $i"
(rdiff-backup --terminal-verbosity 1 --exclude-special-files "$i" "/media/NASBackup/$i")&

cjobs=`jobs | wc -l`

print=0;
while [ $cjobs -ge $maxjobs ]
do
sleep 1
cjobs=`jobs | wc -l`

if [ $cjobs -lt $maxjobs ]
then
print=0
fi

if [ $print -eq 0 ]
then
echo "Running jobs: $cjobs"
fi

print=1
done
done
#Homes backup done

#back up /etc
echo "Backing Up: /etc"
(rdiff-backup --terminal-verbosity 1 --exclude-special-files "/etc" "/media/NASBackup/etc")&

#back up /usr
echo "Backing Up: /usr"
(rdiff-backup --terminal-verbosity 1 --exclude-special-files "/usr" "/media/NASBackup/usr")&

#back up /var/lib/mysql
echo "Backing Up: /var/lib/mysql"
(rdiff-backup --terminal-verbosity 1 --exclude-special-files "/var/lib/mysql" "/media/NASBackup/mysql")&

#back up /var/www
echo "Backing Up: /var/www"
(rdiff-backup --terminal-verbosity 1 --exclude-special-files "/var/www" "/media/NASBackup/www")&

#back up /var/log
echo "Backing Up: /var/log"
(rdiff-backup --terminal-verbosity 1 --exclude-special-files "/var/log" "/media/NASBackup/log")&

#back up /var/spool/amavis
echo "Backing Up: /var/spool/amavis"
(rdiff-backup --terminal-verbosity 1 --exclude-special-files "/var/spool/amavis" "/media/NASBackup/var_spool_amavis")&

#back up /var/lib/amavis
echo "Backing Up: /var/lib/amavis"
(rdiff-backup --terminal-verbosity 1 --exclude-special-files "/var/lib/amavis" "/media/NASBackup/var_lib_amavis")&

Csabi′s BLOG

Linux registered user # 457717