使用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
你应该做那个复制。还要改变你的问题 –
我将很快提供复制解决方案 –