Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 52 lines (49 sloc) 2.25 KB
#!/bin/bash
############################################################################
# Copyright 2011 Greg L. Turnquist
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
############################################################################
#
# This script is used to synchronize working between two machines. It pushes
# an entire directory to another machine.
#
# $1 - source directory
# $2 - target host name
#
# This script assumes that the base folder you run the script in is the same
# base folder targeted by the target server. For example, to push ~/src to
# remote server foobar, type the following command.
#
# localhostmachine:~ me$ rpush src remotemachinename
#
# Typically, it will prompt you for the remote server's password, and should end
# up creating folder remotemahinename:~/src.
#
# In synching, there is the need to delete extraneous files. If you rpush to
# the remote machine, make edits, and then rpush back to the one you started,
# any edits made on localhost will be deleted.
#
############################################################################
rsync -avz --delete --progress $1 $2:
############################################################################
# Q: Why not use some version control system like git? It works great at
# pushing changes back and forth with no risk of deleting changes.
# A: Because in my use case, many of the sub-folders contained in ~/src
# are git projects and git (along with all the others) doesn't lend
# itself to nested structures without introducing too much complexity.
#
# Q: What about services like Dropbox?
# A; I thought about it, but found that I had way too many files than
# I had purchased space for.
############################################################################