# 前言
Hexo 备份,静态文件和源码文件都部署在阿里云
- 本地环境:Node.js、Git
- 本机系统:CentOS Linux release 7.5
# 永久链接
hexo-abbrlink
npm install hexo-abbrlink --save |
# 在 Github 上新建仓库
实际上可以创建多个分支,分别存储源码文件和静态文件
我这里没有仓库就顺便新建一个 myblog.git
# 连接仓库
在 myblog 目录下,初始化一个新本地仓库
git init |
这里就是基本操作
git remote add origin https://github.com/Yourname/myblog |
需要备份的源码文件添加至缓存区
_config.yml
站点的配置文件themes/
主题文件夹下,可以选择需要备份的主题source/
文章的.md 文件scaffolds/
文章的模板package.json
Node.js 需要安装的模块.gitignore
规定在 push 时可以忽略哪些文件
需要删除 themes/Butterfly/.git 文件夹,否则无法 push 主题文件夹
git add _config.yml .gitignore scaffolds/ package.json source/ themes/Butterfly/ |
添加注释并上传
git commit -m "博客备份" | |
git push -u origin master |
这样就备份完成了
# 恢复仓库
这个时候你肯定需要环境,参考以前文章
正常操作至
npm install -g hexo-cli | |
hexo -v |
在 /root 下克隆我们之前备份的仓库
git clone https://github.com/Yourname/myblog |
安装各种之前的依赖模块,启动服务,生成新的 SSH
部署新服务器上记得修改新的站点配置文件
cd myblog | |
npm install | |
hexo g | |
hexo serve | |
git config --global user.name "yourname" | |
git config --global user.email "youremail" | |
git config user.name | |
git config user.email | |
ssh-keygen -t rsa -C "youremail" | |
ssh -T git@github.com | |
npm install hexo-deployer-git --save | |
hexo clean && hexo g && hexo d |
至此,已经迁移完成