hexo-githubpage博客备份与恢复

hexo githubpage 博客备份与恢复

备份起因

我博客的 repo 放在一个vps上 ,它的系统是centos 6.0 特别老了,想折腾一下~

操作步骤

备份

repo 路径: /root/mtq_blog

1
2
3
# pwd
/root
# tar cf mtq_blog.tar ./mtq_blog

恢复

在新机器上安装 git,nodejs,npm
并解压 备份文件

1
2
3
# tar xf mtq_blog.tar

新机器系统是centos7

安装epel源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# yum -y install epel-release
# yum -y update
安装git
# yum install git
安装 nodejs
这里直接安装nodejs的二进制文件,不再折腾了~~
# wget https://nodejs.org/dist/v6.11.2/node-v6.11.2-linux-x64.tar.xz
# tar xf node-v6.11.2-linux-x64.tar.xz
# mv node-v6.11.2-linux-x64 /usr/local/node
# ll /usr/local/node/
total 156
drwxrwxr-x 2 500 500 4096 Aug 13 05:23 bin
-rw-rw-r-- 1 500 500 55990 Aug 1 01:33 CHANGELOG.md
drwxr-xr-x 2 root root 4096 Aug 13 05:22 etc
drwxrwxr-x 3 500 500 4096 Aug 1 01:33 include
drwxrwxr-x 3 500 500 4096 Aug 1 01:33 lib
-rw-rw-r-- 1 500 500 60255 Aug 1 01:33 LICENSE
-rw-rw-r-- 1 500 500 20452 Aug 1 01:33 README.md
drwxrwxr-x 5 500 500 4096 Aug 1 01:33 share
添加环境变量
将以下加入 .bashrc
export PATH=$PATH:/usr/local/node/bin

OK 环境弄好了~
最后还差一步~~
让github 认得你,添加ssh密钥

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# ssh-keygen
会问生成密钥的路径还有另外的密码什么的
当然是一路回车
会在 .ssh文件夹下生成公钥和私钥
# ll
total 16
-rwxr-xr-x 1 root root 380 Jul 31 11:28 authorized_keys
-rw------- 1 root root 1675 Aug 13 04:41 id_rsa
-rw-r--r-- 1 root root 403 Aug 13 04:41 id_rsa.pub
-rw-r--r-- 1 root root 974 Aug 13 04:43 known_hosts
id_rsa 是私钥
id_rsa.pub 是公钥
将公钥复制到GitHub上然后执行
# ssh git@github.com
PTY allocation request failed on channel 0
Hi FranksMa! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.

ok 现在环境都弄好了。可以愉快的胡说八道了

1
# hexo g -d

note: 本文写于成功备份恢复的操作后,看起来一切都ok

放个图片庆祝一下

Photo by Jeff Sheldon on Unsplash
jeff sheldon

图片链接:

Photo by Jeff Sheldon on Unsplash

https://unsplash.com/photos/4IPe3tnBKK0