archive mode
This commit is contained in:
parent
c8028f8895
commit
0a5f0a27ee
@ -8,5 +8,25 @@ user='user'
|
|||||||
ip='ip'
|
ip='ip'
|
||||||
source='/opt /var/www'
|
source='/opt /var/www'
|
||||||
destination='data/'
|
destination='data/'
|
||||||
|
archive_dir='archives/'
|
||||||
|
|
||||||
|
mode='archive'
|
||||||
|
#mode='files'
|
||||||
|
|
||||||
|
if [ "$mode" == "files" ]; then
|
||||||
rsync -a --exclude-from=$exclude_file --password-file=$password_file $source $user@$ip::$destination
|
rsync -a --exclude-from=$exclude_file --password-file=$password_file $source $user@$ip::$destination
|
||||||
|
else
|
||||||
|
mkdir -p $archive_dir
|
||||||
|
|
||||||
|
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 $archive_dir/* $user@$ip::$destination
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
rm -f $archive_dir/*
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user