by Patrick Jezek
@ 29.11.2008 00:22 UTC
Just reminds me: "It's not a bug, it's a feature"
often I make a typo in screen sessions:
ctrl + a AND ctrl + s instead of ctrl + d
screen session seems to be locked, but it has just disabled flow.
pressing ctrl + q enables it again.
Ctrl-s = Xoff (stops the flow)
Ctrl-q = Xon (resumes the flow)
(found @
marc.info)
[ Serverli ]
by Patrick Jezek
@ 27.11.2008 22:32 UTC
this way I backup my mysql databases:
(My old one was bigger and written in php.)
#!/bin/sh
# this script should have access to /root/.my.cnf
export USER=root
export HOME=/root
# get date YYYYMMDD
DATE=`date +%Y%m%d`
# where is the mysql's datadir
DATADIR=`/usr/bin/mysqladmin variables | grep datadir | awk '{print $4}'`
# search for all databases
DATABASES=`cd $DATADIR && find * -type d`
# work dir
WDIR="/home/backup/"
# destination folder/location for backup
DST="SOMEUSER@SOMEHOST:/SOMEPATH/mysql/"
# path to mysqlhotcopy
MYSQLHOTCOPY=/usr/bin/mysqlhotcopy
# create a temp folder
mkdir $WDIR$DATE
# hotcopy all databases
for DATABASE in $DATABASES
do
$MYSQLHOTCOPY -q $DATABASE $WDIR$DATE/
done
# tar all hotcopies
cd $WDIR
tar -zcf mysql_$DATE.tgz $DATE/
# copy backup
cd $WDIR
scp mysql_$DATE.tgz $DST
# clean up tempfiles
cd $WDIR
rm -rf $DATE
rm mysql_$DATE.tgz
[ Serverli ]
by Patrick Jezek
@ 27.11.2008 19:56 UTC
Today I had to rethink my backup strategy on my server!
Until today I used
rdiff-backup to backup my home folder.
On every "restore" I had to reread it's manual :-(
Alain mentioned
rsnap (original written by
Daniel).
I want to keep backups:
- daily backup's for a week
- weekly backup's for a month
- and keep a backup for every month.
So I have written a small wrapper around rsnap:
#!/bin/sh
# get day of month (e.g, 01)
DOM=`date +%d`
# get day of week (0..6); 0 is Sunday
DOW=`date +%w`
# numbers of backup to keep
NOB=
# backup method folder
BMF=
# source folder to backup
SRC="/home/"
# destination folder/location for backup
DST="SOMEUSER@SOMEHOST:/SOMEPATH/home/"
# path to rsnap
RSNAP=/usr/local/bin/rsnap
# choose which backup method:
if [ '01' == $DOM ]; then
echo "first of month -> montly backup!"
NOB=12
BMF="MONTHLY/"
elif [ '0' == $DOW ]; then
echo "it's sunday -> weekly backup!"
NOB=5
BMF="WEEKLY/"
else
echo "do a daily backup!"
NOB=6
BMF="DAILY/"
fi
$RSNAP $NOB $SRC $DST$BMF
Hope this is usefull for someone.
(just replace: SOMEUSER, SOMEHOST, SOMEPATH, SRC and DST)