Appendix III. How to Backup
Last updated
Was this helpful?
Last updated
Was this helpful?
see in Getting Started.
Setup
(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:
(a) Generate SSH key
(b) Copy your keys to the target server
上述操作后,通过ssh到remote server时就可以无需输入密码了,因此下面的步骤也可以在无人值守的时候自动运行。
但如果下面的步骤中你无需登录remote server, 就无需setup ssh key。
(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):
Parameter
Mean
-a:
以递归方式传输文件
--delete:
删除那些接收端还有而发送端已经不存在的文件
-q:
精简输出模式
-z:
在传输文件时进行压缩处理
-H:
保持硬链接文件
-t:
对比两边文件的时间戳和文件大小.如果一致,则就认为两边文件一样,对此文件就不再采取更新动作了
-I:
挨个文件去发起数据同步
--port=PORT:
端口号
打开crontab编辑器:
加入以下行:
Linux将通过crontab定时运行上述命令, 具体定义如下:
Column
Mean
Column 1:
Minutes 0 to 59
Column 2:
Hours 0 to 23 (0 means midnight)
Column 3:
Day 1 to 31
Column 4:
Months 1~12
Column 5:
Week 0 to 7 (0 and 7 for Sunday)
Column 6:
Command to run
Linux 推荐章节:
第25章 LINUX备份策略: 25.2.2完整备份的差异备份; 25.3鸟哥的备份策略; 25.4灾难恢复的考虑; 25.5重点回顾
crontab是Linux中用来定期执行程序的命令, 你可以使用 ,也可以按如下方式自己编辑:
《》 (25章推荐章节)