开发者

Apache Cron Back Up To Github

开发者 https://www.devze.com 2023-03-12 19:02 出处:网络
I\'ve got Apache cron making a back up tar file of my Codeigniter application and placing it in /backup of the server. I\'d like to send t开发者_如何学JAVAhis to Github, but I\'m a little stuck about

I've got Apache cron making a back up tar file of my Codeigniter application and placing it in /backup of the server. I'd like to send t开发者_如何学JAVAhis to Github, but I'm a little stuck about how to do this (my shell script and Git experience is limited).

Any ideas gratefully appreciated.

Thanks!


Sending a tar back to a Git repo (GitHub or not) doesn't strike me as a long-term solution, because Git wouldn't be able to diff that binary file (the tar), and that would rapidely increase the size of that remote repo.

If you still want to do that, it is a simple:

# 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

Then, for the first time:

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

But, for the other instances where you want to push again an updated backup tar file, I would recommend:

# 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.

In other words, the idea would be to not record the history of that file, but to systematically erase the remote version with a new one.

In then end, a directory synchronization service like dropbox (for instance) might be much simpler to use ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号