daily samba backup using crontab
#!/bin/bash
# backup sun01 server : /home/samba_folder
echo `date` 'backup.sh: START' > /tmp/cron.log
cd /
DATESTAMP=`date +%F`
LIST="/tmp/backuplist_$$.txt"
SOURCE_PATH="/home/samba_folder"
DESTINATION_PATH="/media/backup"
OLDBACKUP_PATH="/home/oldbackup"
#mount -n -t cifs -o rw,username=,password= $DESTINATION_PATH
sleep 5
cat /dev/null > /tmp/bcksun01.out
find /tmp/*.ods -cmin +200 -type f -exec rm -f '{}' \; 2>>/dev/null
find /tmp/*.csv -cmin +200 -type f -exec rm -f '{}' \; 2>>/dev/null
#find /home/backup/*.gz -mtime +60 -type f -exec rm -f '{}' \;
set $(date +%d)
if test "$1" = "03" ; then
# rm -f $OLDBACKUP/sun01.admin.full.tar.gz 2>>/dev/null
# tar cvfz "$OLDBACKUP/sun01.admin.full.tar.gz" $SOURCE_PATH/admin 2>>/tmp/cron.log >>/tmp/backup.log
rm -f $OLDBACKUP/sun01.samba_folder.full.tar.gz 2>>/dev/null
tar cvfz "$OLDBACKUP/sun01.samba_folder.full.tar.gz" $SOURCE_PATH 2>>/tmp/cron.log >>/tmp/backup.log
else
rm -f $OLDBACKUP/sun01.samba_folder.$1.tar.gz 2>>/dev/null
find $SOURCE_PATH -depth -type f \( -mtime -2 \) -print > $LIST
tar cvfzT "$OLDBACKUP/sun01.samba_folder.$1.tar.gz" $LIST 2>>/tmp/cron.log >/tmp/backup.log
rm -f "$LIST"
fi
sleep 1
#umount $DESTINATION_PATH/tn_sql
history -c
echo `date` 'backup.sh: Completed' >> /tmp/cron.log
other backup sample
# use backticks " ` ` " to execute shell command
# TARIKH=`date +"%Y%m%d_%s"`
mount -t smbfs //131.107.2.20/volume_1/ /home/vol1 -o username=adabi,password=akula
mount -t smbfs //131.107.2.20/volume_2/ /home/vol2 -o username=adabi,password=akula
TARIKH=`date +"%Y-%m-%d"`
TARIKH2=`date +"%Y%m%d"`
TARIKH3=`date +"%Y%m"`
DAY0=`date +"%d"`
WDAY0=`date +"%u"`
YDATE=`date -d '1 day ago' +'%Y%m%d'`
UPDSCRIPT=update$TARIKH.sh
PATCHSCRIPT=patch$TARIKH.sh
SENARAI=/tmp/bcklist.txt
SENARAIF=/tmp/fbcklist.txt
BCK_TNLINUX3=/home/vol1/tnlinux3
echo ${BCK_TNLINUX3}'/tnlinux3.full.tar.gz' > ${SENARAIF}
echo ${BCK_TNLINUX3}'/tnlinux3.artwork.full.tar.gz' >> ${SENARAIF}
echo ${BCK_TNLINUX3}'/tnlinux3.samba.administrator.full.tar.gz' >> ${SENARAIF}
echo ${BCK_TNLINUX3}'/tnlinux3.samba.customer1.full.tar.gz' >> ${SENARAIF}
yesterday date:
date -d '1 day ago' +'%Y-%m-%d'
or
date -d @`echo $((\`date +%s\` – 86400))` +”%Y-%m-%d”
MYSQL :: SQL LEFT JOIN Syntax
SELECT column_name(s)
FROM table_name1
LEFT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
No comments:
Post a Comment