Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何迁移服务器数据 #949

Open
sylasd opened this issue Jun 17, 2023 · 4 comments
Open

如何迁移服务器数据 #949

sylasd opened this issue Jun 17, 2023 · 4 comments

Comments

@sylasd
Copy link

sylasd commented Jun 17, 2023

有两台服务器,一台安装的去年的老版本的oj程序,还有一台新服务器,安装了最新的oj。
我想把现在旧服务器老版本的题目、用户、用户做题记录等所有数据迁移到另一台新服务器,请问如何操作呢?
是否可以告知下具体的操作步骤,也曾反复查看帮助中心的所有问题介绍,但还是无法解决!

@zhblue
Copy link
Owner

zhblue commented Jun 17, 2023

参考一下hustoj.com, ctrl +f 搜索 迁移

@zhblue
Copy link
Owner

zhblue commented Jun 17, 2023

备份
脚本安装的用户,可以使用 install 目录中的 bak.sh进行备份。

sudo bash /home/judge/src/install/bak.sh
备份后的数据在 /var/backups/ 目录下, 命名格式为 hustoj_%Y%m%d.tar.bz2。

百度学习crontab的用法后,可以使用 sudo crontab -e 定制自动备份计划,部分安装脚本中包含了自动备份,但可能需要运行上面的语句一次来激活。

迁移
首先在新服务器上做全新安装和测试,没有问题后,再迁移数据。

将你需要迁移的归档复制到目标系统的/home/judge/src/install目录下,执行下面的脚本进行恢复( 脚本的第一个参数为恢复的目标归档,20221026 指你实际复制过来的文件名中的日期数字)。

cd /home/judge/src/install
sudo bash restore.sh hustoj_20221026.tar.bz2

@stoneshi4
Copy link

我在恢复时遇到了问题,用的是新机器安装,然后也是用新机器恢复。但无法恢复。终端显示如下
这里有警告是正常现象,请勿担心,下面的打包压缩耗时较长,请耐心等待备份结束,重新回到命令行提示符。 The warning here is normal, don't worry, the following packaging and compression takes a long time, please wait patiently for the backup to end and return to the command line prompt. mkdir: cannot create directory ‘/var/backups’: File exists mysqldump: [Warning] Using a password on the command line interface can be insecure. tar: Removing leading /' from member names
tar: Removing leading /' from hard link targets 备份完成,请检查并用FileZilla通过sftp下载备份文件:/var/backups/hustoj_20231028.tar.bz2 After the backup is complete, please check and download the backup file via sftp with FileZilla: /var/backups/hustoj_20231028.tar.bz2 mv: cannot move '/home/judge/data' to '/home/judge/data.del.20231028/data': Directory not empty mv: cannot move 'home/judge/data' to '/home/judge/data': Directory not empty mv: cannot move '/home/judge/src/web/upload' to '/home/judge/src/web/upload.del.20231028/upload': Directory not empty mv: cannot move 'home/judge/src/web/upload' to '/home/judge/src/web/upload': Directory not empty bzip2: Output file var/backups/db_20231028.sql already exists. mysql: [Warning] Using a password on the command line interface can be insecure. mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 1060 (42S21) at line 3: Duplicate column name 'user_id' ERROR 1060 (42S21) at line 3: Duplicate column name 'user_id'

@zhblue
Copy link
Owner

zhblue commented Oct 28, 2023

如果脚本执行后没有还原备份文件里面的sql数据,可以尝试手工解压,手工恢复。百度一下mysqldump和mysql source命令的使用方法

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants