Appendix III. How to Backup
1) Basic
see Backup your work - Basic in Getting Started.
2) Advanced
(1) Backup your code with GitHub in Terminal
Setup
set up ssh-key (optinal)
add a setting file: ~/.gitconfig
Clone/Download an existed repository on github
Create a new repository
Sync local files with github repo
Pull (update):
Add:
Change:
Remove:
Tips: the bash script to sync a github repo:
(2) Backup data using rsync and crontab
(2.1) Setup ssh key (optional)
(a) Generate SSH key
(b) Copy your keys to the target server
上述操作后,通过ssh到remote server时就可以无需输入密码了,因此下面的步骤也可以在无人值守的时候自动运行。
但如果下面的步骤中你无需登录remote server, 就无需setup ssh key。
(2.2) Prepare a backup script with rsync
(a) First you need to prepare some backup dirs
(b) Then, write a back up script, for example : ~/backup.sh
(c) Last, make your backup.sh excutable
Parameters of rsync (use
man rsync
to see more details):
(2.3) Schedule the back tasks with crontab
crontab是Linux中用来定期执行程序的命令, 你可以使用 在线crontab生成器,也可以按如下方式自己编辑:
打开crontab编辑器:
加入以下行:
Linux将通过crontab定时运行上述命令, 具体定义如下:
(3) More Reading for advanced users
《鸟哥的Linux私房菜-基础学习篇》 (25章推荐章节)
Linux 推荐章节:
第25章 LINUX备份策略: 25.2.2完整备份的差异备份; 25.3鸟哥的备份策略; 25.4灾难恢复的考虑; 25.5重点回顾
Last updated