You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
825 B

1 year ago
#!/bin/bash
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
password_file='/etc/rsyncd.pwd'
exclude_file='/etc/rsyncd.exclude'
user='user'
ip='ip'
source='/opt /var/www'
destination='data/'
1 year ago
archive_dir='archives/'
1 year ago
1 year ago
mode='archive'
#mode='files'
delete_archive=true
#delete_archive=false
1 year ago
if [ "$mode" == "files" ]; then
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 ] && [ "$delete_archive" = true ]; then
1 year ago
rm -f $archive_dir/*
fi
fi