update mysqldump, add imapsync
* remove useless --skip-lock-tables option for mysqldump, already set by --single-transaction * set gzip compression level to 1 instead of 9 : backup process is two times faster, but dump size is only 15% higher * add imapsync script, installation instructions will be added soon
Cette révision appartient à :
Parent
908d4bf031
révision
b144603690
|
@ -10,6 +10,10 @@ A collection of bash scripts
|
|||
|
||||
* [mysqldump](https://github.com/VirtuBox/bash-scripts/blob/master/backup/mysqldump/) : dump each MySQL database or to perform a full dump. Work on almost all linux servers and support Plesk.
|
||||
|
||||
## Mail
|
||||
|
||||
* [imapsync from csv](https://github.com/VirtuBox/bash-scripts/blob/master/mail/imapsync/) : migrate emails between two imap servers by reading users credentials in a csv file using imapsync
|
||||
|
||||
## Cryptocurrency
|
||||
|
||||
* [xmrigCC compilation](https://github.com/VirtuBox/bash-scripts/tree/master/cryptocurrency/xmrigCC) : compile xmrig from source on Ubuntu 16.04/18.04 LTS
|
||||
|
|
|
@ -126,9 +126,9 @@ backup_mysql() {
|
|||
else
|
||||
[ ! -d $MYSQLDUMPPATH/$db ] && $MKDIR -p $MYSQLDUMPPATH/$db
|
||||
if [ -d /etc/psa ]; then
|
||||
MYSQL_PWD=$(cat /etc/psa/.psa.shadow) $MYSQLDUMP -uadmin --single-transaction --skip-lock-tables $db $EXTRA_PARAMS | $GZIP -9 >$FILE || echo -e \\t \\t "MySQLDump Failed $db"
|
||||
MYSQL_PWD=$(cat /etc/psa/.psa.shadow) $MYSQLDUMP -uadmin --single-transaction $db $EXTRA_PARAMS | $GZIP -1 >$FILE || echo -e \\t \\t "MySQLDump Failed $db"
|
||||
else
|
||||
$MYSQLDUMP --single-transaction --skip-lock-tables $db $EXTRA_PARAMS | $GZIP -9 >$FILE || echo -e \\t \\t "MySQLDump Failed $db"
|
||||
$MYSQLDUMP --single-transaction --skip-lock-tables $db $EXTRA_PARAMS | $GZIP -1 >$FILE || echo -e \\t \\t "MySQLDump Failed $db"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
@ -146,9 +146,9 @@ backup_mysql_all_database() {
|
|||
[ ! -d $MYSQLFULLDUMPPATH ] && $MKDIR -p $MYSQLFULLDUMPPATH
|
||||
local FILE="$MYSQLFULLDUMPPATH/all-database.$TIME.gz"
|
||||
if [ -d /etc/psa ]; then
|
||||
MYSQL_PWD=$(cat /etc/psa/.psa.shadow) $MYSQLDUMP -uadmin --all-databases --single-transaction --events --skip-lock-tables | $GZIP -9 >$FILE || echo -e \\t \\t "MySQLDump Failed all-databases"
|
||||
MYSQL_PWD=$(cat /etc/psa/.psa.shadow) $MYSQLDUMP -uadmin --all-databases --single-transaction --events | $GZIP -1 >$FILE || echo -e \\t \\t "MySQLDump Failed all-databases"
|
||||
else
|
||||
$MYSQLDUMP --all-databases --single-transaction --events --skip-lock-tables | $GZIP -9 >$FILE || echo -e \\t \\t "MySQLDump Failed all-databases"
|
||||
$MYSQLDUMP --all-databases --single-transaction --events | $GZIP -1 >$FILE || echo -e \\t \\t "MySQLDump Failed all-databases"
|
||||
fi
|
||||
[ $LOGS -eq 1 ] && echo "*** Backup Finished At $(date) [ files wrote to $MYSQLFULLDUMPPATH] ***" >>$MYSQLDUMPLOG/mysqldumpl.log 2>&1
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
# Script to migrate emails between two servers using imapsync - user credentials read from csv
|
||||
|
||||
## Download the script and csv example
|
||||
|
||||
```bash
|
||||
wget https://raw.githubusercontent.com/VirtuBox/bash-scripts/master/mail/imapsync/imapsync-from-csv.sh -O imapsync-from-csv.sh
|
||||
wget https://raw.githubusercontent.com/VirtuBox/bash-scripts/master/mail/imapsync/credentials.csv -O credentials.csv
|
||||
chmod +x imapsync-from-csv.sh
|
||||
```
|
||||
|
||||
## Run the script
|
||||
|
||||
Put your users crendentials in the csv file, and run imapsync-from-csv.sh this way :
|
||||
|
||||
```bash
|
||||
./imapsync-from-csv.sh imap-server-1.tld imap-server-2.tld
|
||||
```
|
|
@ -0,0 +1,2 @@
|
|||
user@domain.tld | password_imap_1 | password_imap_2
|
||||
user2@domain.tld | password_imap_1 | password_imap_2
|
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
input="credentials.csv"
|
||||
while IFS='|' read -r f1 f2 f3; do
|
||||
imapsync \
|
||||
--host1 "$1" \
|
||||
--user1 "$f1" \
|
||||
--ssl1 \
|
||||
--authmech1 LOGIN \
|
||||
--password1 "$f2" \
|
||||
--host2 "$2" \
|
||||
--ssl2 \
|
||||
--user2 "$f1" \
|
||||
--password2 "$f3" \
|
||||
--authmech2 LOGIN \
|
||||
--automap
|
||||
done <"$input"
|
Chargement…
Référencer dans un nouveau ticket