Commit b384b6c3 authored by HerrHase's avatar HerrHase

change from sftp to rsync

parent 9e7920ff
......@@ -56,11 +56,7 @@ _upload_main()
_upload_options "$@"
_upload_validate
if [ ! -z "${remote_directory}" ]; then
_upload_remote_path=${remote_directory}
fi
rsync -avH --include="${_upload_filename}*" --exclude="*" "${work_directory}/" -e 'ssh -p'${remote_port}'' ${remote_username}@${remote_host}:${_upload_remote_path}
rsync -avH --include="${_upload_filename}*" --exclude="*" "${work_directory}/" -e 'ssh -p '${remote_port}'' ${remote_username}@${remote_host}:${remote_directory}
}
# let it rain
......
......@@ -22,18 +22,18 @@ set -o nounset
#
_backup_tar_clean()
{
rm -r ${work_directory}
if [ ! -z $max_age ]; then
# getting list from remote server and get only filenames
files=$(echo -e "ls -lt ${remote_directory}" | sftp -P ${remote_port} ${remote_username}@${remote_host} | awk '{print $9}')
# getting list from remote server
files=($(rsync --list-only -e 'ssh -p '${remote_port}'' ${remote_username}@${remote_host}:${remote_directory} | awk {'print $5'} | grep -P '^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z.tar.bz2'))
for file in ${files[@]}
do
_backup_tar_check_file "${file}"
done
fi
rm -r ${work_directory}
}
#
......@@ -50,20 +50,12 @@ _backup_tar_check_file()
file_date=${file_date//.tar.bz2/}
file_date=${file_date//_/ }
# check if date is
if [[ "${file_date}" =~ '/\b[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z\b/' ]]; then
# calculate max time and file time
max_time=$(date -d "now - $max_age days" +'%s')
file_time=$(date -d "$file_date" +%s)
if [ ${max_time} -gt ${file_time} ]; then
if [ ! -z "${remote_directory}" ]; then
file=${remote_directory}/$file
fi
# calculate max time and file time
max_time=$(date -d "now - $max_age days" +'%s')
file_time=$(date -d "$file_date" +%s)
echo $(echo -e "rm $file" | sftp -P ${remote_port} ${remote_username}@${remote_host})
fi
if [ ${max_time} -gt ${file_time} ]; then
rsync -avz --delete --ignore-existing --include="${file}" --exclude="*" "${work_directory}/" -e 'ssh -p '${remote_port}'' ${remote_username}@${remote_host}:${remote_directory}
fi
}
......
#!/usr/bin/env bash
#
# download backup, using join to combine archvies
# restore backup, if no argument show files on server
#
# Usage:
# restore.sh <filename>
......@@ -38,8 +38,8 @@ _restore_main()
_restore_options "$@"
if [ -z "${_restore_filename}" ]; then
echo -e "No <\$1>, instead showing files on server"
echo -e "$(echo -e "ls -lt *.tar.bz2*" | sftp -P ${remote_port} ${remote_username}@${remote_host})"
echo -e "No <time>, instead showing files on server"
echo -e "$(rsync --list-only -e 'ssh -p '${remote_port}'' ${remote_username}@${remote_host}:${remote_directory} | grep '.tar.bz2*')"
else
_config_init
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment