More updates!
This commit is contained in:
parent
3967e285b6
commit
c501597c19
10 changed files with 66 additions and 86 deletions
35
linux/sync.sh
Executable file
35
linux/sync.sh
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#!/bin/bash
|
||||
job_name="$1"
|
||||
src="$2"
|
||||
dest="$3"
|
||||
|
||||
# Validate required params.
|
||||
if [[ -z "$job_name" || -z "$src" || -z "$dest" ]]; then
|
||||
echo "Missing required parameter!"
|
||||
echo " Usage: sync.sh [name] [source] [destination]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Bail if the lockfile already exists
|
||||
if [ -f "/tmp/$job_name" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Bail if the source path doesn't exist
|
||||
if [ ! -d "$src" ]; then
|
||||
echo "Source path '$src' does not exist!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Bail if the destination path doesn't exist
|
||||
if [ ! -d "$dest" ]; then
|
||||
echo "Destination path '$dest' does not exist!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create the lockfile
|
||||
touch /tmp/$job_name
|
||||
# Archive, Partial w/ Progress & Preserve Permissions
|
||||
rsync -apP "$src" "$dest"
|
||||
# Remove the lockfile when done
|
||||
rm /tmp/$job_name
|
||||
Loading…
Reference in a new issue