Commit fe50e4b4 authored by Igor Pecovnik's avatar Igor Pecovnik
Browse files

rework #1

parent eb82e894
...@@ -11,84 +11,80 @@ COPY_FROM=/var/www/clients ...@@ -11,84 +11,80 @@ COPY_FROM=/var/www/clients
USER= USER=
PASSWORD= PASSWORD=
HOST=localhost HOST=localhost
#
mkdir -p $COPY_TO mkdir -p $COPY_TO
echo "";
echo "************************************"; function crontab_backup ()
echo " CRONTAB BACKUP"; {
echo "************************************"; echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0mCrontab backup"
echo ""; crontab -l > $COPY_TO/crontab-root.txt
}
crontab -l > $COPY_TO/crontab-root.txt
echo ""; function database_backup ()
echo "************************************"; {
echo " DATABASES BACKUP"; for db in $(echo 'SHOW DATABASES;'|mysql -u$USER -p$PASSWORD -h$HOST|grep -v '^Database$'|grep -v "^performance_schema" |grep -v "^information_schema" |grep -v "^mysql");
echo "************************************"; do
echo ""; mysqldump \
for db in $(echo 'SHOW DATABASES;'|mysql -u$USER -p$PASSWORD -h$HOST|grep -v '^Database$'|grep -v "^performance_schema" |grep -v "^information_schema" |grep -v "^mysql");
do
mysqldump \
-u$USER -p$PASSWORD -h$HOST \ -u$USER -p$PASSWORD -h$HOST \
-Q -c -C --add-drop-table --add-locks --quick --lock-tables \ -Q -c -C --add-drop-table --add-locks --quick --lock-tables \
$db | gzip --best -c > $COPY_TO/$DBBACKUPNAME-$db.sql.gz; $db | gzip --best -c > $COPY_TO/$DBBACKUPNAME-$db.sql.gz;
echo "Backup of" $db; echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0mDatabase $db backup"
done; done;
}
echo "";
echo "************************************";
echo " WEB BACKUP"; function web_backup ()
echo "************************************"; {
echo ""; echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0mWebsites backup"
for x in $(find $COPY_FROM -maxdepth 2 -name "web*" -type d -print0 | xargs -0)
echo "Wait a moment please..."; do
for x in $(find $COPY_FROM -maxdepth 2 -name "web*" -type d -print0 | xargs -0) tar -cpvzf $COPY_TO/$WEBBACKUPNAME-$(basename $x).tar.gz $x &> /dev/null
do done;
tar -cpvzf $COPY_TO/$WEBBACKUPNAME-$(basename $x).tar.gz $x &> /dev/null }
done;
echo ""; function conf_backup ()
echo "************************************"; {
echo " CONF BACKUP"; /etc/init.d/scanbuttond stop
echo "************************************"; /etc/init.d/vpnserver stop
echo ""; service transmission-daemon stop
service tvheadend stop
service dovecot stop service cups stop
service cups stop service samba stop
service transmission-daemon stop echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0mConf files backup"
service hostapd stop tar cvPfz $COPY_TO/$FILEBACKUPNAME-allfiles.tgz -T filelist.txt --exclude='*.sock'
service postfix stop service samba start
service tvheadend stop service cups start
service samba stop service tvheadend start
/etc/init.d/scanbuttond stop service transmission-daemon start
/etc/init.d/vpnserver stop /etc/init.d/scanbuttond start
# backup only minimum /etc/init.d/vpnserver start
tar cvPfz $COPY_TO/$FILEBACKUPNAME-allfiles.tgz -T filelist.txt --exclude='*.sock' }
echo "";
echo "************************************"; function mail_backup ()
echo " MAIL BACKUP"; {
echo "************************************"; service dovecot stop
echo ""; service postfix stop
echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0mMail backup"
# tar cvPfz $COPY_TO/$FILEBACKUPNAME-mail.tgz /var/vmail
tar cvPfz $COPY_TO/$FILEBACKUPNAME-mail.tgz /var/vmail service postfix start
# service dovecot start
service dovecot start }
service cups start
service transmission-daemon start
service hostapd start function pkglist_backup ()
service postfix start {
service tvheadend start echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0mPackage list backup"
service samba start aptitude search '~i !~M !~pstandard !~pimportant !~prequired' | awk '{print $2}' > $COPY_TO/installedpackages
/etc/init.d/scanbuttond start }
/etc/init.d/vpnserver start
echo ""; # main app
echo "************************************"; crontab_backup
echo " INSTALLED PACKAGE LIST BACKUP"; database_backup
echo "************************************"; web_backup
echo ""; conf_backup
aptitude search '~i !~M !~pstandard !~pimportant !~prequired' | awk '{print $2}' > $COPY_TO/installedpackages mail_backup
pkglist_backup
\ No newline at end of file
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
/usr/local/bin/.sync /usr/local/bin/.sync
/etc/mysql/my.cnf /etc/mysql/my.cnf
/etc/default/stunnel4 /etc/default/stunnel4
/usr/local/vpnserver/vpn_server.config
/usr/bin/tv_grab_file /usr/bin/tv_grab_file
/home/hts/.hts/tvheadend /home/hts/.hts/tvheadend
/etc/samba/smb.conf /etc/samba/smb.conf
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment