mysql , mongodb 備份

一,準備:mysql

    automysqlbackup 下載: https://sourceforge.net/projects/automysqlbackup/git

    automongobackup 下載: https://github.com/micahwedemeyer/automongobackupgithub

    automongobackup是模仿automysqlbackup項目寫的,默認並不帶配置文件,能夠直接修改腳本里對應變量。sql


二,automysqlbackup 配置:mongodb

        CONFIG_mysql_dump_username='user'
        CONFIG_mysql_dump_password='passwd'
        CONFIG_mysql_dump_host='localhost'
        CONFIG_backup_dir='/backup/mysql'
        CONFIG_multicore='yes'
        CONFIG_multicore_threads=2
        CONFIG_do_monthly="0"
        CONFIG_do_weekly="0"
        CONFIG_rotation_daily=6
        CONFIG_mysql_dump_port=3306
        CONFIG_mysql_dump_single_transaction='yes'
        CONFIG_mysql_dump_compression='gzip'


automongobackup 配置:shell

DBHOST="127.0.0.1"
DBPORT="27017"
BACKUPDIR="/backup/mongodb"
DBUSERNAME="user"
DBPASSWORD="passwd"
DBAUTHDB="admin"
MAILCONTENT="stdout"
MAXATTSIZE="4000"
DODAILY="yes"
DAILYRETENTION=6
DOWEEKLY="no"
WEEKLYDAY=0
WEEKLYRETENTION=0
DOMONTHLY="no"
MONTHLYRETENTION=0
COMP="gzip"
CLEANUP="yes"
LATEST="yes"
LATESTLINK="yes"
OPLOG="no"
REPLICAONSLAVE="yes"
REQUIREDBAUTHDB="yes"

兩個配置都指定備份文件保存一星期spa


三,執行:.net

/usr/local/bin/automysqlbackup /etc/automysqlbackup/myserver.conf
automongobackup


四,數據導入rest

mongodb:code

mongorestore -h 127.0.0.1 -d dbname dbbakdir/

mysql:

mysql -uusername -ppassword < bak.sql
相關文章
相關標籤/搜索