Maybe some old friend may wonder why I have not write for two months. Well, I say sorry here for my laziness. During the last two month I was busy with study for a driving license, working for my graduation thesis, and playing an great game called “Mount & Blade — Prophesy of Pendor”. Besides, I have ordered an new VPS which supports Netflix, and migrated my blog to it. Now I’d like to record how I did it.
Backup my website
Firstly, I had to backup my files and database. When I firstly built up the Blog, I used BT panel, which can easily set up or back up an website automatically. However, because of my limited budget, I cannot afford an vps with large memory. Thus, if I use the panel, the vps is not stable because of lacking memory, so I set up LCMP (Linux, Caddy, Mysql, Php) environment and my blog (WordPress) again manually.
Backing up files was simple, just use tar command.
cd /var/www tar cjxvf jerryding.tar.bz2 jerryding.tk/
In the command above, “cjpvf” means “create, filter through bzip2, preserve permissions, verbose,file”. However, when it comes to database, it is not so easy. After searching methods via google and trying for several times, I finally make it.
mysqldump -u root -p jerryding_site > /var/www/backup.sql
Firstly I used scp, but then I found that rsync is much faster.
rsync -e 'ssh -p 1234' --progress [email protected]:SourceFile DestFile
After fetching all files to my laptop, including jerryding.tk.tar.bz2, backup.sql, Caddyfile, v2ray/config.json, and so on, I installed debian 9 on my new vps, set up LCMP environment, reconfig domain name resolution, and upload my files by the same command.
rsync -e 'ssh -p 1234' --progress SourceFile [email protected]:DestFile
After MySQL was installed, the database of the website can be restored this way:
mysql -u root -p create database jerryding_site; grant all privileges on jerryding_site.* to 'jerryding_site'@'localhost' identified by 'PASSWORD'; use jerryding_site; source /path/to/backup.sql;