【问题标题】:Apache Cron Back Up To GithubApache Cron 备份到 Github
【发布时间】:2011-06-13 11:56:06
【问题描述】:

我已经让 Apache cron 为我的 Codeigniter 应用程序制作了一个备份 tar 文件,并将其放在服务器的 /backup 中。我想将它发送到 Github,但我对如何执行此操作有点困惑(我的 shell 脚本和 Git 经验有限)。

感谢任何想法。

谢谢!

【问题讨论】:

    标签: apache git shell github


    【解决方案1】:

    将 tar 发送回 Git 存储库(无论是否是 GitHub)对我来说并不是一个长期的解决方案,因为 Git 无法区分该二进制文件(tar),而且会迅速增加该远程仓库的大小。

    如果你还想这样做,很简单:

    # declare a dedicated repo on your GitHub account
    git clone git@github.com:user/repo.git/BackupRepo . # where the backup is
    git checkout -b backup # make a special branch
    git push origin backup # create that branch on the GitHub repo
    

    那么,第一次:

    # create your backup tar file
    git add .
    git commit -m "backup file"
    git push
    

    但是,对于您想要再次推送更新的备份 tar 文件的其他情况,我建议:

    # update your backup tar file
    git add .
    git commit --amend # modify the existing commit instead of creating a new one.
    git push -f # force the push to replace the remote commit by this updated one.
    

    换句话说,这个想法是不记录该文件的历史记录,而是用一个新文件系统地删除远程版本

    最后,像dropbox(例如)这样的目录同步服务可能更容易使用;)

    【讨论】:

      猜你喜欢
      • 2020-11-14
      • 2011-08-10
      • 1970-01-01
      • 2010-11-18
      • 2013-05-07
      • 1970-01-01
      • 2011-06-01
      • 1970-01-01
      • 2010-12-07
      相关资源
      最近更新 更多