问题原文
原帖链接 · Killbots2012 · CC BY-SA 4.0
I'm trying to use this bash script to create and send the tar.gz file to my backup server, some reason it doesn't seem to copy it, is there a better solution to what I'm trying to do?
I'd rather have it compressed before I send it over the network
#!/bin/bash
####################################
#
# Backup to NFS mount script.
#
####################################
# What to backup.
backup_files="/home/amp/.ampdata/instances/Towny/"
# Where to backup to.
dest="/home/amp/Backups"
# Create archive filename.
day=$(date +%A)
time=$(date +%H-%M)
file=$(file)
archive_file="$file-$day-$time.tgz"
# Print start status message.
echo "Backing up $backup_files to $dest/$archive_file"
date
echo
# Backup the files using tar.
tar czf $dest/$archive_file $backup_files
rsync $archive_file [email omitted]:~/backup
# Print end status message.
echo
echo "Backup finished"
date
已采纳解答
原帖链接 · Michael Hampton · CC BY-SA 4.0
Everywhere in your script you refer to $dest/$archive_file as the file you wish to create and copy, except in the rsync command that is supposed to copy it to the other host. Fix the call to rsync and try again.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
