update scripts
This commit is contained in:
parent
7fdd965197
commit
7ab83e358d
@ -1,77 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
FTP_CREDS="/root/backup/ftpserver.login"
|
|
||||||
|
|
||||||
BACKUP_SYSTEM="bin boot dev lib mnt opt sbin usr"
|
|
||||||
BACKUP_CONFIG="etc"
|
|
||||||
BACKUP_USER="home root"
|
|
||||||
BACKUP_VAR="var"
|
|
||||||
|
|
||||||
# ------------------
|
|
||||||
|
|
||||||
umask 0077
|
|
||||||
TODAY=`date +%Y-%m-%d`
|
|
||||||
OLDDAY=`date +%Y-%m-%d -d '-6 months'`
|
|
||||||
TMPDIR=`mktemp -d`
|
|
||||||
|
|
||||||
# ------------------
|
|
||||||
|
|
||||||
function create_backup {
|
|
||||||
echo "## "`date`
|
|
||||||
target=$1
|
|
||||||
shift
|
|
||||||
rm -rf $target
|
|
||||||
tar --totals -czpf $target -C / $@ 2>&1
|
|
||||||
/usr/bin/md5sum -b $target
|
|
||||||
echo
|
|
||||||
}
|
|
||||||
|
|
||||||
function ftp_push_delete {
|
|
||||||
echo "## "`/bin/date`
|
|
||||||
target=$1
|
|
||||||
shift
|
|
||||||
|
|
||||||
# workaround -X %s bug in ncftpput (do not use absolute local paths)
|
|
||||||
pushd . &> /dev/null
|
|
||||||
cd $TMPDIR
|
|
||||||
for file in $@; do
|
|
||||||
files="$files `/usr/bin/basename $file`"
|
|
||||||
done
|
|
||||||
/usr/bin/ncftpput -V -X "SITE CHMOD 600 %s" -f $FTP_CREDS $target $files
|
|
||||||
popd &> /dev/null
|
|
||||||
# end workaround
|
|
||||||
|
|
||||||
echo
|
|
||||||
}
|
|
||||||
|
|
||||||
function ftp_list {
|
|
||||||
echo "## "`date`
|
|
||||||
ftp_host=`/usr/bin/awk '/host/{ print $2 }' $FTP_CREDS`
|
|
||||||
/usr/bin/ncftpls -l -f $FTP_CREDS ftp://${ftp_host}/
|
|
||||||
echo
|
|
||||||
}
|
|
||||||
|
|
||||||
function ftp_delete {
|
|
||||||
echo "delete $1"
|
|
||||||
ftp_host=`/usr/bin/awk '/host/{ print $2 }' $FTP_CREDS`
|
|
||||||
/usr/bin/ncftpls -l -f $FTP_CREDS -X "DELE $1" ftp://${ftp_host}/ &> /dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
# ------------------
|
|
||||||
|
|
||||||
create_backup $TMPDIR/backup-${TODAY}-system.tar.gz $BACKUP_SYSTEM
|
|
||||||
create_backup $TMPDIR/backup-${TODAY}-config.tar.gz $BACKUP_CONFIG
|
|
||||||
create_backup $TMPDIR/backup-${TODAY}-user.tar.gz $BACKUP_USER
|
|
||||||
create_backup $TMPDIR/backup-${TODAY}-var.tar.gz $BACKUP_VAR
|
|
||||||
|
|
||||||
ftp_push_delete / $TMPDIR/backup-${TODAY}-*.tar.gz
|
|
||||||
|
|
||||||
ftp_delete backup-${OLDDAY}-system.tar.gz
|
|
||||||
ftp_delete backup-${OLDDAY}-config.tar.gz
|
|
||||||
ftp_delete backup-${OLDDAY}-user.tar.gz
|
|
||||||
ftp_delete backup-${OLDDAY}-var.tar.gz
|
|
||||||
|
|
||||||
ftp_list
|
|
||||||
|
|
||||||
echo "FTP backup completed."
|
|
||||||
rm -rf $TMPDIR
|
|
@ -1,4 +0,0 @@
|
|||||||
# ftp-server account data (chmod 0600!)
|
|
||||||
host ftp.server.net
|
|
||||||
user bla
|
|
||||||
pass blub
|
|
28
full-system-backup/backup.conf
Normal file
28
full-system-backup/backup.conf
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
MAILADDRESS="ore@kashyyyk"
|
||||||
|
|
||||||
|
#LOCAL_STORAGE_PATH="/var/backups.system"
|
||||||
|
#LOCAL_STORAGE_KEEP="1 month"
|
||||||
|
|
||||||
|
REMOTE_STORAGE_TYPE="ftp"
|
||||||
|
REMOTE_STORAGE_KEEP="6 months"
|
||||||
|
REMOTE_STORAGE_HOST="10.10.250.133"
|
||||||
|
REMOTE_STORAGE_CRED="backup:test"
|
||||||
|
REMOTE_STORAGE_PATH="/"
|
||||||
|
|
||||||
|
BACKUPS="system config home source"
|
||||||
|
|
||||||
|
BACKUP_system="tar"
|
||||||
|
BACKUP_system_FILES="/"
|
||||||
|
BACKUP_system_EXCLUDE="/home /proc /sys /tmp /var/tmp /usr/src /usr/local/src /var/cache/apt/archives"
|
||||||
|
|
||||||
|
BACKUP_config="tar"
|
||||||
|
BACKUP_config_FILES="/etc /usr/local/etc /boot/$(hostname).* /boot/grub/menu.lst"
|
||||||
|
|
||||||
|
BACKUP_home="tar"
|
||||||
|
BACKUP_home_EXCLUDE="/home/ftp /home/newsnet /home/squid /home/oldsystem"
|
||||||
|
BACKUP_home_FILES="/home"
|
||||||
|
|
||||||
|
BACKUP_source="tar"
|
||||||
|
BACKUP_source_FILES="/usr/src /usr/local/src"
|
249
full-system-backup/full-system-backup
Executable file
249
full-system-backup/full-system-backup
Executable file
@ -0,0 +1,249 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#DEBUG="true"
|
||||||
|
#DEBUG_CLEANUP="true"
|
||||||
|
|
||||||
|
CONFIG="$1"
|
||||||
|
[ -n "$CONFIG" ] || CONFIG="/etc/backup.conf"
|
||||||
|
[ -f "$CONFIG" ] || exit 1
|
||||||
|
|
||||||
|
DATE="$(date +%Y-%m-%d)"
|
||||||
|
BACKUP_PREFIX="$(hostname).$DATE"
|
||||||
|
|
||||||
|
umask 0077
|
||||||
|
tmpdir=$(mktemp -d) || exit 1
|
||||||
|
|
||||||
|
. $CONFIG
|
||||||
|
|
||||||
|
[ -n "$LOCAL_STORAGE_PATH" -a ! -d "$LOCAL_STORAGE_PATH" ] && {
|
||||||
|
echo "directory does not exist: <${LOCAL_STORAGE_PATH}>"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# log to stderr when debugging
|
||||||
|
[ -z "$DEBUG" ] && exec 2>${tmpdir}/msg
|
||||||
|
|
||||||
|
filesize() {
|
||||||
|
du -shcx $1 2>/dev/null | awk '/total/{ printf("%4s",$1); }'
|
||||||
|
}
|
||||||
|
|
||||||
|
filestat() {
|
||||||
|
format="[%A] %U(%u):%G(%g)"
|
||||||
|
[ -b "$1" -o -c "$1" ] && format="$format Maj:%T Min:%t"
|
||||||
|
stat -c "$format %N" $1 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
storage() {
|
||||||
|
FILENAME="$1"
|
||||||
|
|
||||||
|
# put file in local storage directory and copy it later to remote storage
|
||||||
|
if [ -n "$LOCAL_STORAGE_PATH" ]; then
|
||||||
|
cat > ${LOCAL_STORAGE_PATH}/${FILENAME}
|
||||||
|
echo "$FILENAME: ($(filesize ${LOCAL_STORAGE_PATH}/${FILENAME}))" >&2
|
||||||
|
|
||||||
|
# copy file only via ssh
|
||||||
|
elif [ "$REMOTE_STORAGE_TYPE" == "ssh" ]; then
|
||||||
|
ssh $REMOTE_STORAGE_HOST "cat > ${REMOTE_STORAGE_PATH}/${FILENAME}"
|
||||||
|
|
||||||
|
# copy file only via ftp
|
||||||
|
elif [ "$REMOTE_STORAGE_TYPE" == "ftp" ]; then
|
||||||
|
ncftpput $ftp_cred -U 0077 -V -c $REMOTE_STORAGE_HOST "${REMOTE_STORAGE_PATH}/${FILENAME}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# assumes '.' as seperator and date (YYYY-MM-DD) in 2nd field
|
||||||
|
# eg. $(hostname).$(date).tar.gz)
|
||||||
|
calcold() {
|
||||||
|
filelist="$1"
|
||||||
|
keep="$2"
|
||||||
|
cut -d'.' -f2 $filelist > ${filelist}.dates
|
||||||
|
date -d "-${keep}" "+%Y-%m-%d-XXX" >> ${filelist}.dates
|
||||||
|
sort -r -u < ${filelist}.dates > ${filelist}.dates.uniq
|
||||||
|
|
||||||
|
cnt=0
|
||||||
|
mark=0
|
||||||
|
for datestamp in $(cat $filelist.dates.uniq); do
|
||||||
|
if $(echo $datestamp | grep -q "XXX"); then
|
||||||
|
mark=1
|
||||||
|
continue;
|
||||||
|
fi
|
||||||
|
|
||||||
|
cnt=$[cnt +1]
|
||||||
|
# keep at least this +1 backups, even if it's older
|
||||||
|
if [ "$cnt" -gt 1 -a "$mark" = "1" ]; then
|
||||||
|
grep "$datestamp" $filelist
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "$(basename $0) running on $(hostname) [${DATE}]" >&2
|
||||||
|
|
||||||
|
if [ -n "$LOCAL_STORAGE_PATH" ]; then
|
||||||
|
echo "LOCAL_STORAGE: $LOCAL_STORAGE_PATH (keep $LOCAL_STORAGE_KEEP)" >&2
|
||||||
|
else
|
||||||
|
echo "LOCAL_STORAGE: none" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$REMOTE_STORAGE_TYPE" in
|
||||||
|
ftp) # ftp server
|
||||||
|
ftp_user=$(echo $REMOTE_STORAGE_CRED | cut -d':' -f1)
|
||||||
|
ftp_pass=$(echo $REMOTE_STORAGE_CRED | cut -d':' -f2)
|
||||||
|
ftp_cred="-u $ftp_user -p $ftp_pass"
|
||||||
|
|
||||||
|
[ -z "$REMOTE_STORAGE_PATH" ] && REMOTE_STORAGE_PATH="/"
|
||||||
|
echo "REMOTE_STORAGE: ftp://${REMOTE_STORAGE_HOST}/${REMOTE_STORAGE_PATH} (keep $REMOTE_STORAGE_KEEP)" >&2
|
||||||
|
;;
|
||||||
|
|
||||||
|
ssh) # ssh / scp
|
||||||
|
[ -z "$REMOTE_STORAGE_PATH" ] && REMOTE_STORAGE_PATH="."
|
||||||
|
[ -n "$REMOTE_STORAGE_BANDWIDTH" ] && REMOTE_STORAGE_BANDWIDTH="-l $REMOTE_STORAGE_BANDWIDTH"
|
||||||
|
echo "REMOTE_STORAGE: ssh://${REMOTE_STORAGE_HOST}:${REMOTE_STORAGE_PATH} (keep $REMOTE_STORAGE_KEEP)" >&2
|
||||||
|
;;
|
||||||
|
|
||||||
|
*) echo "REMOTE_STORAGE: none" >&2
|
||||||
|
REMOTE_STORAGE_TYPE="none"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
created_files=""
|
||||||
|
for name in $BACKUPS; do
|
||||||
|
eval type=\${BACKUP_${name}}
|
||||||
|
|
||||||
|
echo -e "\nBACKUP_$name: (type: ${type})" >&2
|
||||||
|
|
||||||
|
case "$type" in
|
||||||
|
tar) # tar.gz of files
|
||||||
|
eval files=\${BACKUP_${name}_FILES}
|
||||||
|
eval exclude=\${BACKUP_${name}_EXCLUDE}
|
||||||
|
|
||||||
|
for i in $files; do
|
||||||
|
echo " adding $i" >&2
|
||||||
|
done
|
||||||
|
|
||||||
|
excluded="--exclude $tmpdir"
|
||||||
|
[ -n "$LOCAL_STORAGE_PATH" ] && excluded="$excluded --exclude $LOCAL_STORAGE_PATH"
|
||||||
|
for tmp in $exclude; do
|
||||||
|
echo " excluding $(filestat $tmp)" >&2
|
||||||
|
excluded="${excluded} --exclude ${tmp}"
|
||||||
|
done
|
||||||
|
|
||||||
|
filename="${BACKUP_PREFIX}.${name}.tar.gz"
|
||||||
|
[ -n "$files" ] && tar --numeric-owner -C / -czf - $excluded $files | storage $filename
|
||||||
|
;;
|
||||||
|
|
||||||
|
mysql) # mysql dump of some/all tables
|
||||||
|
eval user=\${BACKUP_${name}_USER}
|
||||||
|
eval pass=\${BACKUP_${name}_PASS}
|
||||||
|
eval db_list=\${BACKUP_${name}_DBS}
|
||||||
|
|
||||||
|
auth="-u${user} -p${pass}"
|
||||||
|
[ -n "$pass" ] || auth="-u ${user}"
|
||||||
|
|
||||||
|
if [ -z "$db_list" ]; then
|
||||||
|
db_list=$(echo "show databases;" | /usr/bin/mysql ${auth} -r --column-name=FALSE)
|
||||||
|
fi
|
||||||
|
|
||||||
|
mysql_schema_dump="/usr/bin/mysqldump ${auth} --opt --all --no-data"
|
||||||
|
mysql_data_dump="/usr/bin/mysqldump ${auth} --opt --add-locks=FALSE --no-create-info"
|
||||||
|
|
||||||
|
created_mysql_files=""
|
||||||
|
for db in $db_list; do
|
||||||
|
echo " database $db" >&2
|
||||||
|
|
||||||
|
$mysql_schema_dump --databases $db > ${tmpdir}/${db}-schema.sql
|
||||||
|
$mysql_data_dump --databases $db > ${tmpdir}/${db}-data.sql
|
||||||
|
created_mysql_files="$created_mysql_files ${db}-schema.sql ${db}-data.sql"
|
||||||
|
done
|
||||||
|
|
||||||
|
filename="${BACKUP_PREFIX}.${name}.tar.gz"
|
||||||
|
[ -n "$created_mysql_files" ] && tar -C $tmpdir -czf - $created_mysql_files | storage $filename
|
||||||
|
;;
|
||||||
|
|
||||||
|
ldap) # slapcat of slapd database
|
||||||
|
filename="${BACKUP_PREFIX}.${name}.ldif.gz"
|
||||||
|
slapcat | gzip | storage $filename
|
||||||
|
;;
|
||||||
|
|
||||||
|
*) echo "Invalid backup type: <${type}>" >&2
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
created_files="$created_files $filename"
|
||||||
|
done
|
||||||
|
|
||||||
|
[ -n "$created_files" ] || {
|
||||||
|
echo -e "\nERROR(?): no files created." >&2
|
||||||
|
rm -rf $tmpdir
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
# store a log (only when not debugging)
|
||||||
|
if [ -z "$DEBUG" ]; then
|
||||||
|
cat ${tmpdir}/msg | storage ${BACKUP_PREFIX}.log
|
||||||
|
created_files="$created_files ${BACKUP_PREFIX}.log"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$LOCAL_STORAGE_PATH" ]; then
|
||||||
|
|
||||||
|
local_files=""
|
||||||
|
# check files & prefix with local path
|
||||||
|
for created in $created_files; do
|
||||||
|
[ -e "${LOCAL_STORAGE_PATH}/${created}" ] && local_files="$local_files ${LOCAL_STORAGE_PATH}/${created}"
|
||||||
|
done
|
||||||
|
|
||||||
|
# copy local files to remote storage
|
||||||
|
case "$REMOTE_STORAGE_TYPE" in
|
||||||
|
ftp) echo -e "\ncopy archives to REMOTE_STORAGE" >&2
|
||||||
|
ncftpput $ftp_cred -U 0077 -V $REMOTE_STORAGE_HOST $REMOTE_STORAGE_PATH $local_files
|
||||||
|
;;
|
||||||
|
|
||||||
|
ssh) echo -e "\ncopy archives to REMOTE_STORAGE" >&2
|
||||||
|
scp -p -q $REMOTE_STORAGE_BANDWIDTH $local_files "${REMOTE_STORAGE_HOST}:${REMOTE_STORAGE_PATH}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# cleanup local storage
|
||||||
|
echo -e "\nremoving old (> $LOCAL_STORAGE_KEEP) backups from LOCAL_STORAGE" >&2
|
||||||
|
|
||||||
|
{ cd ${LOCAL_STORAGE_PATH}; ls -1 $(hostname).* > ${tmpdir}/local.files; }
|
||||||
|
local_old_files=$(calcold ${tmpdir}/local.files "$LOCAL_STORAGE_KEEP")
|
||||||
|
|
||||||
|
for old_file in $local_old_files; do
|
||||||
|
echo " removing $old_file ($(filesize $old_file))" >&2
|
||||||
|
[ -z "$DEBUG_CLEANUP" ] && rm -f ${LOCAL_STORAGE_PATH}/${old_file}
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# cleanup remote storage
|
||||||
|
case "$REMOTE_STORAGE_TYPE" in
|
||||||
|
ftp) echo -e "\nremoving old (> $REMOTE_STORAGE_KEEP) backups from REMOTE_STORAGE" >&2
|
||||||
|
|
||||||
|
ncftpls $ftp_cred "ftp://${REMOTE_STORAGE_HOST}${REMOTE_STORAGE_PATH}" > ${tmpdir}/remote.files
|
||||||
|
remote_old_files=$(calcold ${tmpdir}/remote.files "$REMOTE_STORAGE_KEEP")
|
||||||
|
|
||||||
|
for old_file in $remote_old_files; do
|
||||||
|
echo " removing $old_file" >&2
|
||||||
|
[ -z "DEBUG_CLEANUP" ] && \
|
||||||
|
ncftpls $ftp_cred -X "DELE $old_file" "ftp://${REMOTE_STORAGE_HOST}${REMOTE_STORAGE_PATH}" > /dev/null
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
|
||||||
|
ssh) echo -e "\nremoving old (> $REMOTE_STORAGE_KEEP) backups from REMOTE_STORAGE" >&2
|
||||||
|
|
||||||
|
ssh $REMOTE_STORAGE_HOST "cd ${REMOTE_STORAGE_PATH}; ls -1 $(hostname).*" > ${tmpdir}/remote.files
|
||||||
|
remote_old_files=$(calcold ${tmpdir}/remote.files "$REMOTE_STORAGE_KEEP")
|
||||||
|
|
||||||
|
if [ -n "$remote_old_files" ]; then
|
||||||
|
remote_old_paths=""
|
||||||
|
for old_file in $remote_old_files; do
|
||||||
|
echo " removing $old_file" >&2
|
||||||
|
remote_old_paths="$remote_old_paths ${REMOTE_STORAGE_PATH}/${old_file}"
|
||||||
|
done
|
||||||
|
[ -z "$DEBUG_CLEANUP" ] && ssh $REMOTE_STORAGE_HOST "rm $remote_old_paths"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
[ -n "$MAILADDRESS" -a -z "$DEBUG" ] && mail -s "full-system-backup on $(hostname)" $MAILADDRESS < ${tmpdir}/msg
|
||||||
|
|
||||||
|
rm -rf $tmpdir
|
Binary file not shown.
@ -1,102 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
DEBIAN_MIRROR="http://ftp2.de.debian.org"
|
|
||||||
UBUNTU_MIRROR="http://de.archive.ubuntu.com"
|
|
||||||
|
|
||||||
sarge_i386_URL="${DEBIAN_MIRROR}/debian/dists/sarge/main/installer-i386/current/images/hd-media/boot.img.gz"
|
|
||||||
sarge_i386_FILE=../debian/sarge/i386_img.gz
|
|
||||||
sarge_i386_NAME="Debian 3.1 Sarge (i386)"
|
|
||||||
sarge_i386_SHORT="sarge"
|
|
||||||
|
|
||||||
etch_i386_URL="${DEBIAN_MIRROR}/debian/dists/etch/main/installer-i386/current/images/hd-media/boot.img.gz"
|
|
||||||
etch_i386_FILE=../debian/etch/i386_img.gz
|
|
||||||
etch_i386_NAME="Debian 4.0 Etch (i386)"
|
|
||||||
etch_i386_SHORT="etch"
|
|
||||||
|
|
||||||
etch_amd64_URL="${DEBIAN_MIRROR}/debian/dists/etch/main/installer-amd64/current/images/hd-media/boot.img.gz"
|
|
||||||
etch_amd64_FILE=../debian/etch/amd64_img.gz
|
|
||||||
etch_amd64_NAME="Debian 4.0 Etch (amd64)"
|
|
||||||
etch_amd64_SHORT="etch64"
|
|
||||||
|
|
||||||
edgy_i386_URL="${UBUNTU_MIRROR}/ubuntu/dists/edgy/main/installer-i386/current/images/netboot/boot.img.gz"
|
|
||||||
edgy_i386_FILE=../ubuntu/edgy/i386_img.gz
|
|
||||||
edgy_i386_NAME="Ubuntu 6.10 Edgy Eft (i386)"
|
|
||||||
edgy_i386_SHORT="edgy"
|
|
||||||
|
|
||||||
edgy_amd64_URL="${UBUNTU_MIRROR}/ubuntu/dists/edgy/main/installer-amd64/current/images/netboot/boot.img.gz"
|
|
||||||
edgy_amd64_FILE=../ubuntu/edgy/amd64_img.gz
|
|
||||||
edgy_amd64_NAME="Ubuntu 6.10 Edgy Eft (amd64)"
|
|
||||||
edgy_amd64_SHORT="edgy64"
|
|
||||||
|
|
||||||
feisty_i386_URL="${UBUNTU_MIRROR}/ubuntu/dists/feisty/main/installer-i386/current/images/netboot/boot.img.gz"
|
|
||||||
feisty_i386_FILE=../ubuntu/feisty/i386_img.gz
|
|
||||||
feisty_i386_NAME="Ubuntu 7.04 Feisty Fawn (i386)"
|
|
||||||
feisty_i386_SHORT="feisty"
|
|
||||||
|
|
||||||
feisty_amd64_URL="${UBUNTU_MIRROR}/ubuntu/dists/feisty/main/installer-amd64/current/images/netboot/boot.img.gz"
|
|
||||||
feisty_amd64_FILE=../ubuntu/feisty/amd64_img.gz
|
|
||||||
feisty_amd64_NAME="Ubuntu 7.04 Feisty Fawn (amd64)"
|
|
||||||
feisty_amd64_SHORT="feisty64"
|
|
||||||
|
|
||||||
DISTLIST="sarge_i386 etch_i386 etch_amd64 edgy_i386 edgy_amd64 feisty_i386 feisty_amd64"
|
|
||||||
|
|
||||||
# -------------------
|
|
||||||
|
|
||||||
CFG="isolinux.cfg"
|
|
||||||
TXT="isolinux.txt"
|
|
||||||
|
|
||||||
echo "DISPLAY $TXT" > $CFG
|
|
||||||
echo "PROMPT 1" >> $CFG
|
|
||||||
echo "KBDMAP german.kbd" >> $CFG
|
|
||||||
|
|
||||||
echo -e "\nAvailable bootdisks:" > $TXT
|
|
||||||
|
|
||||||
for dist in $DISTLIST; do
|
|
||||||
eval URL=\${${dist}_URL}
|
|
||||||
eval FILE=\${${dist}_FILE}
|
|
||||||
eval NAME=\${${dist}_NAME}
|
|
||||||
eval SHORT=\${${dist}_SHORT}
|
|
||||||
|
|
||||||
[ -e "$FILE" ] || {
|
|
||||||
DIR=$(dirname $FILE)
|
|
||||||
mkdir -p $DIR $DIR/temp.org $DIR/temp.new
|
|
||||||
|
|
||||||
# fetch & decompress big original
|
|
||||||
ORGFILE=${FILE%.gz}.org.gz
|
|
||||||
wget -O $ORGFILE $URL
|
|
||||||
gunzip $ORGFILE
|
|
||||||
|
|
||||||
# mount & get used size
|
|
||||||
mount -o loop ${ORGFILE%.gz} $DIR/temp.org || exit
|
|
||||||
SIZE=$(du -s $DIR/temp.org | awk '{ x=$1+512; printf "%.0f", x/1024; }')
|
|
||||||
|
|
||||||
# create dosfs with min size
|
|
||||||
dd if=/dev/zero of=${FILE%.gz} bs=1M count=$SIZE
|
|
||||||
mkdosfs ${FILE%.gz}
|
|
||||||
|
|
||||||
# mount & copy
|
|
||||||
mount -o loop ${FILE%.gz} $DIR/temp.new || exit
|
|
||||||
cp -a $DIR/temp.org/* $DIR/temp.new
|
|
||||||
|
|
||||||
# cleanup
|
|
||||||
umount $DIR/temp.org || exit
|
|
||||||
umount $DIR/temp.new || exit
|
|
||||||
rm -rf ${ORGFILE%.gz} $DIR/temp.org $DIR/temp.new
|
|
||||||
|
|
||||||
# make it bootable (needs syslinux + mtools)
|
|
||||||
syslinux ${FILE%.gz}
|
|
||||||
gzip ${FILE%.gz}
|
|
||||||
}
|
|
||||||
|
|
||||||
echo -e "\nLABEL $SHORT" >> $CFG
|
|
||||||
echo " KERNEL memdisk" >> $CFG
|
|
||||||
echo " APPEND initrd=${FILE#..}" >> $CFG
|
|
||||||
printf "%-10s - %s\n" "$SHORT" "$NAME" >> $TXT
|
|
||||||
done
|
|
||||||
|
|
||||||
[ -e "isolinux.bin" ] || cp /usr/lib/syslinux/isolinux.bin .
|
|
||||||
[ -e "memdisk" ] || cp /usr/lib/syslinux/memdisk .
|
|
||||||
|
|
||||||
mkisofs -b isolinux/isolinux.bin -c isolinux/boot.cat \
|
|
||||||
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
|
||||||
-l -N -o /tmp/multi-dist-$(date "+%Y-%m-%d").iso ..
|
|
@ -1,46 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
DB_USER="root"
|
|
||||||
DB_PASS="password"
|
|
||||||
|
|
||||||
SCP_HOST="remote.server"
|
|
||||||
SCP_USER="username"
|
|
||||||
SCP_PATH="backups/"
|
|
||||||
|
|
||||||
STOR="/home/dbbackup/"
|
|
||||||
STOR_USER="dbbackup:root"
|
|
||||||
STOR_PERM="0600"
|
|
||||||
STOR_DAYS="7"
|
|
||||||
|
|
||||||
# -------------
|
|
||||||
|
|
||||||
DUMP_SCHEMA="/usr/bin/mysqldump --opt --all --no-data"
|
|
||||||
DUMP_DATA="/usr/bin/mysqldump --opt --add-locks=FALSE --no-create-info"
|
|
||||||
|
|
||||||
umask 0077
|
|
||||||
NOW=`date +%Y-%m-%d-%H-%M`
|
|
||||||
TMPDIR=`mktemp -d`
|
|
||||||
mkdir -p $TMPDIR/$NOW
|
|
||||||
|
|
||||||
# generate dumps
|
|
||||||
db_list=`echo "show databases;" | /usr/bin/mysql -u${DB_USER} -p${DB_PASS} -r --column-name=FALSE`
|
|
||||||
for db in $db_list; do
|
|
||||||
$DUMP_SCHEMA -u${DB_USER} -p${DB_PASS} --databases $db > $TMPDIR/$NOW/$db-schema.sql
|
|
||||||
$DUMP_DATA -u${DB_USER} -p${DB_PASS} $db > $TMPDIR/$NOW/$db-data.sql
|
|
||||||
done
|
|
||||||
|
|
||||||
# pack dumps together
|
|
||||||
tar -czf database-$NOW.tar.gz -C $TMPDIR $NOW
|
|
||||||
|
|
||||||
# upload
|
|
||||||
/usr/bin/scp -q $TMPDIR/database-$NOW.tar.gz ${SCP_USER}@${SCP_HOST}:${SCP_PATH}
|
|
||||||
|
|
||||||
# move to storage
|
|
||||||
chmod $STOR_PERM $TMPDIR/database-$NOW.tar.gz
|
|
||||||
chown $STOR_USER $TMPDIR/database-$NOW.tar.gz
|
|
||||||
mv $TMPDIR/database-$NOW.tar.gz $STOR
|
|
||||||
|
|
||||||
# delete old files in storage
|
|
||||||
find $STOR -mtime +$STOR_DAYS -exec rm {} \;
|
|
||||||
|
|
||||||
rm -rf $TMPDIR
|
|
5
ssh-copy-login
Executable file
5
ssh-copy-login
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
ssh-copy-id -i ~/.ssh/id_rsa.pub $1
|
||||||
|
|
||||||
|
ssh $@
|
3
ssh-remove-host
Executable file
3
ssh-remove-host
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
sed -i -e "/$1/d" ~/.ssh/known_hosts
|
28
update-bind-forwarders.sh
Executable file
28
update-bind-forwarders.sh
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
NAMED_CONF="/etc/bind/named.conf.options"
|
||||||
|
|
||||||
|
[ "$USEPEERDNS" ] || exit 0
|
||||||
|
[ "$DNS1" -a "$DNS2" ] || exit 0
|
||||||
|
|
||||||
|
# replace forwarders
|
||||||
|
awk '/forwarders {/ { active = 1; print } \
|
||||||
|
/};/ { \
|
||||||
|
if ( active == 1 ) { \
|
||||||
|
active = 0; \
|
||||||
|
print "\t\t" f1 ";"; \
|
||||||
|
print "\t\t" f2 ";"; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
{ \
|
||||||
|
if ( active == 0 ) \
|
||||||
|
print; \
|
||||||
|
} ' \
|
||||||
|
f1=$DNS1 f2=$DNS2 $NAMED_CONF > ${NAMED_CONF}.${PPP_IFACE}
|
||||||
|
|
||||||
|
mv ${NAMED_CONF}.${PPP_IFACE} $NAMED_CONF
|
||||||
|
|
||||||
|
# restart if running
|
||||||
|
[ -f "/var/run/bind/run/named.pid" ] && rdnc reconfig
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue
Block a user