CS Student Server - rsync

The easiest way to copy files from your computer to the cs-student server for testing is with rsync.

Installing rsync

Mac/Linux will already have rsync available and do not need to do anything. Windows users need to follow these steps to set up the bash command prompt that is included with git to allow you to use the rsync program.

  1. Install git for Windows (if you do not already have it)

  2. Download this zip file that contains rsynch for git bash. Inside of the .zip file are four files. You need to copy those four files (not the .zip itself) to the directory C:\Program Files\Git\usr\bin (if you installed git to a non-standard location, look for the usr\bin directory in that location).

    The four files placed in the usr\bin folder of Git

This will add the rsync command to Git's bash terminal. To test it, close Git bash if it is already running, then open Git bash from the start menu. It will provide you a terminal that uses linux style commands. Type rsync and hit enter. If you get a long help message followed by an error from rsync, all is good. If you get a short "command not found" message, rsync is not installed.

Any time you want to use rsync, you will need to use this terminal and not the Windows command prompt. Some tips for doing so:

CommandFunction
pwdShow the directory you are in
lsList the files in your current directory
ls -laList the files in that location including hidden files and information about the files
cd /cGo to the root level of your C drive
cd /c/Users/YOURNAMEGo to your home folder in Windows

Using rsync

To upload files to the server

From a terminal window (must be Git bash if on Windows) on your local computer, navigate to the location that contains the folder you want to copy to the server. For instance, if you want to copy the folder Assign5 that is in the folder cs162, you should navigate to the cs162 folder. Then do the following, but replace FOLDERNAME with the name of the folder you are trying to copy (like Assign5).

rsync -a FOLDERNAME USERNAME@cs-student.chemeketa.edu:~/

This will prompt you for your password (for your server account) and then copy the local folder FOLDERNAME to your home directory on the server.

To verify, use another terminal window to ssh into the server and verify that the folder is now on the server in your home directory.

If you rerun the rsync command, it will copy any changes from your local files to the server. Assuming you want to edit files on your PC and test on the server, you can make changes locally, then rerun rsync to upload those files to the server.

To download files from the server

In general, it is recommened you do all your editing locally and upload changes to the server. Although it is possible to edit files on the server and then copy those to your local machine, this opens the door to by accident overwriting more recent local files with remote ones.

If you do find yourself wanting to download files from the server onto your local machine, you can also use rsync for that:

rsync -a USERNAME@cs-student.chemeketa.edu:PATH .

The PATH you specify should be the name of the folder or file you want to copy from the server will be interpreted relative to your home directory on the server. The . specifies the destination as the current working directory on your local machine.

Cleaning Up

When you are done testing some code on the folder, you can delete it by navigating to the directory above it (the place where you can do ls and see the folder listed) and doing rm -rf to it:

rm -rf FOLDERNAME

-r stands for "recursive" - delete all the files and folders inside the named folder. The f stands for "force" - go ahead and delete files without asking for confirmation.