Shell Script Backup Error

Asked

Viewed 44 times

0

Guys,I’m trying to make a script in which when plugging the USB stick into the pc, it would synchronize the files from certain folder of the USB stick to the pc.

I created a udev rule so that when the USB stick is connected the backuppendrive.sh will run

Script Code:

#!/bin/bash

LOG=/var/log/backuppendrive.log
exec 1>>${LOG}
exec 2>&1

echo > /var/log/backuppendrive.log

DEVICE="$1"

echo "Dispositivo: $DEVICE"

mount -U 184F39D627BEE814 /mnt/

rsync -uahvP /mnt/ETEC /home/mateus/ETEC/teste

umount /mnt/$DEVICE

exit 0

Log when script runs automatically:

Dispositivo: sdb1
fusermount: mount failed: Operation not permitted
sending incremental file list
rsync: link_stat "/mnt/ETEC" failed: No such file or directory (2)

sent 18 bytes  received 12 bytes  60.00 bytes/sec
total size is 0  speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1189) [sender=3.1.3]
umount: /mnt/sdb1: must be superuser to unmount.

Log when I run the script manually:

Dispositivo: 
Mount is denied because the NTFS volume is already exclusively opened.
The volume may be already mounted, or another software may use it which
could be identified for example by the help of the 'fuser' command.
sending incremental file list
rsync: link_stat "/mnt/ETEC" failed: No such file or directory (2)

sent 18 bytes  received 12 bytes  60.00 bytes/sec
total size is 0  speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1189) [sender=3.1.3]
umount: /mnt/: não montado.

What am I doing wrong ?

1 answer

0

In the script the variable is assigned DEVICE="$1" the first argument the program receives, possibly when you run in hand ./script you are not passing that argument. You also have to run this script with root permission because you mount and demonist disk drives.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.