Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
sep:internal:personalbackup [2019/01/07 08:45]
cabrales
sep:internal:personalbackup [2019/01/29 03:13] (current)
milad
Line 8: Line 8:
  
 =====Using Git===== =====Using Git=====
 +
 +* Git is a useful but quite a complex tool. This instructions do not pretend to be more than 1% exhaustive. Some people claim that, after 5 or more years using git they do not get a full grasp (do not look at me; I have spend a little bit less than two years!) Internet is your friend, so look there for answers when requiring something more complex than what I present in this tutorial (or make an appointment with Bob).
  
 ==== 1. Creating a Git repository==== ==== 1. Creating a Git repository====
Line 23: Line 25:
          git add myfile1.txt          git add myfile1.txt
  
-  * You can type "git status" to verify that myfile1.txt was added and ready to be committed, whereas myfile2.txt remains untracked. Here myfile1.txt represents files and folders suitable for being backup, such as source codes, makefiles and possibly parameters files. On the contrary, myfile2.txt represents all that you should not incorporate into the backup, such as binaries, results, etc.+  * You can type "git status" to verify that myfile1.txt was added and ready to be committed, whereas myfile2.txt remains untracked. Here myfile1.txt represents files and folders suitable for being backed up, such as source codes, makefiles and possibly parameters files. On the contrary, myfile2.txt represents all that you should not incorporate into the backup, such as binaries, results, etc.
    
 +
 ====  3. Commit your changes==== ====  3. Commit your changes====
   * Once you added the files, you create the local backup using git commit:   * Once you added the files, you create the local backup using git commit:
Line 30: Line 33:
          git commit -m "This is my backup"          git commit -m "This is my backup"
  
-  * Notice that I have added label "-m" which allows to write a message or comment associated to the backup. I strongly recommend you to take advantage of this, for it is easy to lose track of the changes that one makes in one's codes. If you are constantly changing you code, either debugging or testing, it can be wise to commit, for instance, before any "major surgery" that you are palling in your codes, commenting the current status and what you are about to do.+  * Notice that I have added label "-m" which allows to write a message or comment associated to the backup. I strongly recommend you to take advantage of this, for it is easy to lose track of the changes that one makes in one's codes. If you are constantly changing your code, either debugging or testing, it can be wise to commit, for instance, before any "major surgery" that you are palling in your codes, commenting the current status and what you are about to do.
  
-====  4. Push to remote repository==== +====  4. Create remote repository (you make this only once)==== 
-  * The final step is to push the local repository to the server.+  * The final step is to push the local repository to the server. However, you must first create the remote repository towards which you will push. Please take a look at this simple tutorial to learn how to create it:  {{:sep:internal:New.git.project.pdf}}
  
-==Introduction of rsync and crontab == 
- 
-  * Introduction of rsync 
-  rsync is a software application and network protocol for Unix-like and Windows systems that synchronizes files and directories from one location to another while minimizing data transfer using delta encoding when appropriate. 
- In the backup procedure, rsync is used to synchronize your files and directories from the server to your local computer. 
-  * Introduction of crontab 
- A cron is a utility that allows tasks to automatically run in the background of the system at regular intervals by use of the cron daemon. Crontab (CRON TABle) is a file, which contains the schedule of cron entries to be run, and at what times they are to be run.  
- In the backup procedure, crontab is quite useful, which helps you do the backup once a day without manual operation.  
- 
-==Detailed description of the workflow == 
- 
-  * **1. Make a directory in your local computer for backup**            
-        
-              
-         e.g. mkdir ~/backup  
- 
-  * **2. Copy the //rsync// script to your backup directory** 
-Download the python script {{:sep:internal:backup.py}} (click on the name). 
-  * **3. Change the script** 
-There are two major parts that need to be changed in the script //backup.py// (currently the web backup is not performed, thus I commented the corresponding lines out). Such parts are circled in the following figure.  
-  
- {{:sep:internal:script1.png}} 
-  
-. 
- 
-. 
- 
-. 
- 
- 
-   
-The upper red circle means the directory in your local mac that you want to back up to. The lower red circle means the directory in the server that you want to back up. In this example I back up my home directory in **oas**, cabrales. You can change them into your desired directory. Don’t forget to remove/add the //for// loop in the script if you plan to back up other than this directory, and change the server name accordingly. I use oas in this example (circled in blue). Notice if your user name on your mac is **different** from the user name on oas, you need to add the oas user name in the blue circle, i.e.  from **oas => my_oas_username@oas**. 
- 
-  * **4. [Optional] Set up a notification** 
- Disregard this. Growl is no longer freeware. 
- 
- 
-  * **5. Create a cron schedule** 
-  * (1) Type "crontab –e" in the terminal window.  
-The text editor will open a blank window for the “crontab entries” to be entered. Each line presents a separate cron jobs. 
-  * (2) Put the following line in the window and remember to change the directory 
- 
-     
-    * * * * * /Users/YourNameInMacDirectory/backup/backup.py 
- 
-If you used vi for the edition, when you exit you'll get the message: "crontab: installing new crontab." 
- 
-An asterisk (*) is used to indicate that every instance (i.e. every hour, every weekday, etc.) of the particular time period will be used. 
-Here is how positions 1-5 are layed out: 
- 
-|1| Minute 0-59| 
-|2 |Hour 0-23 (0 = midnight)| 
-|3 |Day 1-31| 
-|4 |Month 1-12| 
-|5 |Weekday 0-6 (0 = Sunday) | 
- 
-  * (3) Change asterisks (*) accordingly 
-Find you name and the time for you to back up in the following table. The starting time means your backup script will automatically run at this particular time. Then change * * * * * according to the corresponding format. For example, my command would look: 
- 
-  40 3 * * * /Users/alejandrocabrales/backup/backup.py 
- 
- 
-^^^ 
-^  Name      Starting Time ^         Format      
-^ Fantine Huot  |00:00 am |0 0 * * *| 
-^ Joe Jennings   |00:20 am |20 0 * * *| 
-^ Taylor Dahlke |00:40 am |40 0 * * *| 
-^ Guillaume Barnier |01:00 am |0 1 * * *| 
-^ Ettore Biondi |01:20 am |20 1 * * *| 
-^ Yinbin Ma |01:40 am |40 1 * * *| 
-^ Jon Claerbout |02:00 am |0 2 * * *| 
-^ Biondo Biondi |02:20 am |20 2 * * *| 
-^ Rahul Sarkar |02:40 am |40 2 * * *| 
-^ Bob Clapp |03:00 am |0 3 * * *| 
-^ Jason Chang |03:20 am |20 3 * * *| 
-^ Alejandro Cabrales |03:40 am |40 3 * * *| 
-^ Huy Le |04:00 am |0 4 * * *| 
-^ Stuart Farris |04:20 am |20 4 * * *| 
-^ Eileen Martin |04:40 am |40 4 * * *| 
-^ Rustam Akhmadiev |05:00 am |0 5 * * *| 
-^ Siyuan Yuan |05:20 am |20 5 * * *| 
-^ Stew Levin |05:40 am |40 5 * * *| 
-^ Shuki Ronen |06:00 am |0 6 * * *| 
-^ Miguel Ferrier |06:20 am |20 6 * * *| 
-^^^^^^ 
- 
-IMPORTANT: Crontab won't work unless your computer is awake.  
- 
-  * 6. **[Optional] Check the success of your crontab** 
-Type “ls -ltr /var/mail”, and check the time in the following information 
- 
-       "-rw-------  1 yishen  mail  5559 Mar 14 1:40 yishen" 
- 
-  
-==Notice== 
-The first backup may take a while, possibly exceeding 20 minutes. Manually running the script for your first backup during the weekend or in the evening instead of using crontab is recommended.  To run the script manually, type the following command in your back up directory.  
  
-  ./backup.py 
  
-(Ps: probably you will be asked to connect to the server at your first time.) 
  
 +====  5. Push to remote repository====
 +  * The final step is to push the local repository to the server. Simply type
  
 +         git push
  
 +  * If you get no error message, congratulations! Your commits went to the remote repository.
  
  
sep/internal/personalbackup.1546850757.txt.gz · Last modified: 2019/01/07 08:45 by cabrales
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0