Although I do not code any more recently, I keep on the good habit of versioning.
Bascially, I have a local git repository on my desktop and all the files I work with (text, keynotes, excel, scripts...) are located inside.
I do changes and commit them as I would do with code. With git, it's simple and efficient. Git logs are also a good way to know what I worked on on a given date, very convenient for reporting.
The only remaining problem was related to backup. Indeed, if my laptop disk crashes, I would lose everything. I'm not allowed to set up a git repository at work, but our IT provides everybody with a shared private folder. The advantage of this shared folder is that IT performs backup every night.
The first thing I did, was just to move my directory on the shared folder. It worked great...until I wanted to access my files from a location without the network! So, the repository on the shared folder was not a solution.
I decided to create a backup git repository on the shared folder. This way, I would still work on the laptop and I would have a backup on the shared drive.
Here is the set of commands to do this. I'll suppose that the shared folder has been mounted on drive x:\ and that my repository is located in c:\repo_git :
First, we create the backup repository:
cd x:\ mkdir repo_git_backup cd repo_git_backup git init . --barebare option means that the repository will only contain git database files. You cannot perform any checkout on the repository. It's OK for my use case, because I just need a backup.
We can register our new repository, we will name it backup:
cd c:\repo_git git remote add backup file://x:/repo_git_backupNow everything is in place. In order to start a backup, just execute:
git push backup masterIn case your git repository contains a lot of file or has a long history, it may take some time. Afterwards, it should be must faster.
Let's say that my disk crashes, I will lose all the data in c:\repo_git . How to I retrieve the files from the backup? Just create a folder and execute:
git clone file://x:/git_repo_backupEverything will be back to the latest "git push".
In order to push automatically, I decided to create a scheduled task running the following powershell script, I'll describe it in a next post.
No comments:
Post a Comment