1

I need help for shell script, this script on my pc works ubuntu 14.10 but on samba server machine ubuntu 14.04 is show me error: tar you may not specify more than one -acdtrux' option --delete or test-label.... Please help. Script is for archive files older to 10 days. There is script:

#!/bin/sh

# What to backup. 
backup_files="/usr/*"

# Where to backup to.
dest="/home/milan/Desktop"

# Create archive filename.
day=$(date +%F)
hostname=$(hostname -s)
archive_file="$hostname-$day.tgz"

# Print start status message.
echo "Backing up $backup_files to $dest/$archive_file"
date
echo

# Backup the files using tar.
files=$(find $backup_files -type f -mtime -10)
sudo -s tar cf $dest/$archive_file $files

#files=($(find /usr -mtime -7))
#tar cvfz $dest/$archive_file.tar.gz "${files[@]}"

# Print end status message.
echo
echo "Backup finished"
date

# Long listing of files in $dest to check file sizes.
ls -lh $dest
4
  • 3
    Use More Quotes™. Also, with this approach you'll end up with a duplicate of every file for every day. Wouldn't you rather use a version control system like git or a plain file copy like rsync?
    – l0b0
    Aug 5, 2015 at 7:10
  • Ok, but i need to make script for backup on samaba on every 10 days Aug 5, 2015 at 7:28
  • Like l0b0 said rsynch is better. Plus you can schedule that with cron Aug 5, 2015 at 7:36
  • 2
    Please edit your question and answer the questions from the comments. Do you still need help with the matter?
    – dessert
    May 31, 2018 at 7:55

0

You must log in to answer this question.

Browse other questions tagged .