Answer the question
In order to leave comments, you need to log in
Why does the script not work when the folder is mounted?
Since the ssd drives, the site backup simply does not fit, so I immediately mount the external drive as a local device,
mount it in different ways, but it doesn’t really affect
mount -t davfs https://XXXXXXXXXX.your-storagebox.de/ /var/backup
mount.cifs -o user=XXXXX,pass=XXXXXXX //XXXXXXXX.your-storagebox.de/ /mnt
#!/bin/sh
test ! -d /var/backup/mysql/`date +%Y` && { mkdir -p /var/backup/mysql/`date +%Y` ; }
test ! -d /var/backup/mysql/last && { mkdir -p /var/backup/mysql/last ; }
chmod 600 /var/backup/mysql
chmod 600 /var/backup/mysql/last
for i in `mysql -uroot -pXXXXXXXXX -e'show databases;' | grep -v information_schema | grep -v Database`; do mysqldump -uroot -pXXXXXXX $i > /var/backup/mysql/last/$i.sql;done >> /dev/null 2>> /var/log/sqlbackup.log
cd /var/backup/mysql/
tar -czvf /var/backup/mysql/`date +%Y`/sqldump-`date +%Y-%m-%u`.tar.gz ./last >> /dev/null > /var/log/sqlbackup.log
# БЭКАП /etca
test ! -d /var/backup/etc/ && { mkdir -p /var/backup/etc/ ; }
DATE=`date +%F`;
BACKUPPATH="/var/backup/etc";
find $BACKUPPATH/ -mtime +60 | xargs rm -f; #удаляет предыдущие бэкапы старше 60 дней.
tar -czvf "$BACKUPPATH/etc.$DATE.tar.gz" /etc/ > /dev/null 2> /dev/null;
mkdir: cannot create directory ‘/var/backup/mysql/2017’: Permission denied
mkdir: cannot create directory ‘/var/backup/mysql/last’: Permission denied
chmod: cannot access ‘/var/backup/mysql/last’: Permission denied
tar: ./last: Cannot stat: Permission denied
tar (child): /var/backup/mysql/2017/sqldump-2017-11-6.tar.gz: Cannot open: Permission denied
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question