使用mysqldump的爲:
mysqldump -hREMOTE_HOST -uroot -pREMOTEpwd --opt --compress REMOTEdb | mysql -uroot -pLOCALpwd LOCALdb
此命令可以執行在目標服務器上,它將提取源數據庫的內容,重新創建所有表和數據。
使用這種方法需要關閉數據庫服務器的源 以避免丟失數據。
2.按照後續要求,你需要增量備份計劃。
增量備份僅備份自 以前的備份以來更改的數據。該技術爲設計備份策略提供了額外的靈活性,並減少了備份所需的存儲空間。
增量備份通過選項啓用,該選項指向mysqlbackup命令。
樣的命令行參數來啓動mysqlbackup
是:
# Information about data files can be retrieved through the database connection.
# Specify connection options on the command line.
mysqlbackup --user=dba --password --port=3306 \
--with-timestamp --backup-dir=/export/backups \
backup
# Or we can include the above options in the configuration file
# under [mysqlbackup], and just specify the configuration file
# and the 'backup' operation.
mysqlbackup --defaults-file=/usr/local/mysql/my.cnf backup
# Or we can specify the configuration file as above, but
# override some of those options on the command line.
mysqlbackup --defaults-file=/usr/local/mysql/my.cnf \
--compress --user=backupadmin --password --port=18080 \
backup
的--user
和我們指定--password
用於連接到MySQL服務器。
--with-timestamp
選項將備份放置在我們上面指定的目錄下創建的子目錄中。備份子目錄的名稱由備份運行的日期和時鐘時間組成。
請參閱完整參考here和here。
這將是很好,如果我想合併整個數據庫,但我只想合併它的一部分。例如,網站#13正在將其內容填充到測試數據庫中,而網站#2已經在生產數據庫上運行了幾個月。如何在生產數據庫上合併#13的數據而不丟失#2的數據。 – 0x1ad2
你應該做那個複製。還要改變你的問題 –
我將很快提供複製解決方案 –