• 请不要在回答技术问题时复制粘贴 AI 生成的内容
bramblex
V2EX  ›  程序员

Git 同步配置文件方案,再也不怕丢配置文件了

  •  
  •   bramblex ·
    bramblex · Aug 28, 2016 · 4462 views
    This topic created in 3627 days ago, the information mentioned may be changed or developed.

    Gist 代码:

    Gist 代码: https://gist.github.com/bramblex/9e888771e63be95e93d817b8199f3c65

    基本使用:

    跟踪配置文件

    # 1. 建立一个 github 仓库
    
    # 2. clone 仓库 ~/.autobackup
    abu init <git 仓库>
    
    # 3. 把配置文件加入跟踪
    abu add <file>
    
    # 4. 同步 git 仓库
    abu sync
    
    # 5. 生成计划任务,每 30 分钟同步一次。(只有使用 ssh 协议并且上传了 public key 的才能自动同步。)
     abu cron
    

    在新环境一键恢复所有配置

    # 1. clone 已有的 abu 仓库到本地 ~/.autobackup
    abu init <git 仓库>
    
    # 2. 一键恢复所有已备份配置文件
    abu restore
    

    比如我自己的配置仓库是长这样 https://github.com/bramblex/ConfigAutoBackup

    所有选项

        init        初始化 abu 仓库
        cron        创建 crontab 计划任务
        add         跟踪配置文件
        remove      将文件从跟踪中删除
        list        列出所有被跟踪的文件
        status      当前同步状态,相当于 git status
        sync        同步至远端 git 仓库
        restore     一键从 abu 仓库中恢复所有配置文件。
    

    截图

    http://ww4.sinaimg.cn/mw690/699d3e11gw1f79f11w54rj20h70ayae7.jpg

    6 replies    2016-08-29 09:09:43 +08:00
    oh8
        1
    oh8  
       Aug 28, 2016
    弱弱的问一下,这个 terminal 是装了啥插件吗?显示路径和各种颜色啥的。
    simple2025
        2
    simple2025  
       Aug 28, 2016
    同步什么配置?
    cuminflea
        3
    cuminflea  
       Aug 28, 2016 via iPad
    可以试试 mackup
    bramblex
        4
    bramblex  
    OP
       Aug 28, 2016
    @cuminflea

    我是拿来备份一些命令行下面的 dot file 。并不是应用数据……

    而且往往是 osx / linux 上面都需要进行同步,而不仅仅是 osx ……
    ooonme
        5
    ooonme  
       Aug 28, 2016 via iPhone
    @oh8 oh my zsh
    cuminflea
        6
    cuminflea  
       Aug 29, 2016 via iPad
    @bramblex 嗯嗯, mackup 就是备份 dotfile 的,它的实现应该和你差不多,你的还简洁点。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3041 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 14:25 · PVG 22:25 · LAX 07:25 · JFK 10:25
    ♥ Do have faith in what you're doing.