Compare commits
No commits in common. "4dae05ba2c5aa7e367400e50506191088586a529" and "a9aba2cdf46476cb36ee12dea202479922610f33" have entirely different histories.
4dae05ba2c
...
a9aba2cdf4
@ -16,39 +16,20 @@ mode='archive'
|
||||
delete_archive=true
|
||||
#delete_archive=false
|
||||
|
||||
archive_with_date=true
|
||||
#archive_with_date=false
|
||||
|
||||
if ! which rsync >/dev/null 2>&1; then
|
||||
echo "rsync is not installed. Installing..."
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y rsync
|
||||
fi
|
||||
|
||||
if [ "$mode" == "files" ]; then
|
||||
rsync -a --exclude-from=$exclude_file --password-file=$password_file $source $user@$ip::$destination
|
||||
else
|
||||
mkdir -p $archive_dir
|
||||
|
||||
if [ "$archive_with_date" = true ]; then
|
||||
today=$(date +"%Y%m%d")
|
||||
archive_dir="$archive_dir/$today"
|
||||
mkdir -p $archive_dir
|
||||
fi
|
||||
|
||||
for dir in $source; do
|
||||
if [ "$archive_with_date" = true ]; then
|
||||
archive_name=$(echo $dir | tr '/' '_').tar.gz
|
||||
tar -czf $archive_dir/$archive_name $dir
|
||||
else
|
||||
archive_name=$(basename $dir).tar.gz
|
||||
tar -czf $archive_dir/$(date +"%Y%m%d")-$archive_name $dir
|
||||
fi
|
||||
for dir in $source
|
||||
do
|
||||
archive_name=$(date +"%Y%m%d")-$(echo $dir | tr '/' '_').tar.gz
|
||||
tar -czf $archive_dir/$archive_name $dir
|
||||
done
|
||||
|
||||
rsync -a --exclude-from=$exclude_file --password-file=$password_file --relative $archive_dir/ $user@$ip::$destination
|
||||
rsync -a --exclude-from=$exclude_file --password-file=$password_file $archive_dir/* $user@$ip::$destination
|
||||
|
||||
if [ $? -eq 0 ] && [ "$delete_archive" = true ]; then
|
||||
rm -rf $archive_dir/*
|
||||
rm -f $archive_dir/*
|
||||
fi
|
||||
fi
|
Loading…
Reference in New Issue
Block a user