Posted by Dan Sosedoff
on September 18, 2009
Here is the bash shell script that makes archived dumps of your database server. All databases are separated from each other and stored into date based folders.
#!/bin/bash
MyUSER="root"
MyPASS=""
MyHOST="localhost"
NOW="$(date +"%d-%m-%Y")"
STOREDIR="/home/storage/backup/database/by_dates/$NOW"
DBLIST="$(mysql -u $MyUSER -h $MyHOST -Bse 'show databases')"
[ ! -d $STOREDIR ] && mkdir -p $STOREDIR || :
for db in $DBLIST
do
FILE="$STOREDIR/$db.gz"
mysqldump -u $MyUSER -h $MyHOST $db | gzip -9 > $FILE
done
Posted by Dan Sosedoff
on June 28, 2009
First, we need to install all dependencies:
# yum install gettext-devel expat-devel curl-devel zlib-devel openssl-devel
Next, get the git 1.6.x sources:
# wget http://kernel.org/pub/software/scm/git/git-1.6.3.3.tar.gz
Then, unpack and cd into git sources folder and install it:
# make && make install & make clean
That`s it, now you`ll have git system ready to go.
Posted by Dan Sosedoff
on March 09, 2009
For example, in your bash shell script you`re going to use some root-specific commands like network operations, mounting devices and so on. There are couple easy ways to check if your script is executing under root privileges.
#!/bin/bash
# ...
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# ...
Another way: use EUID. When user account created a user ID is assigned to each user. Bash shell stores the user ID in $UID variable. Your effective user ID is stored in $EUID variable.
#!/bin/bash
# ...
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# ...