خرید بک لینک

I have two exteal drives,and both are now formatted as EXT4. To synchronise the two drives, I have written a bash that checks they are mounted and then runs rsync. However, since Backup1 is an SSD, I also want to run fstrim before they are synchronised.

While the mount and rsync bits appear to work perfectly, depending on whether or not I use sudo, I get one of the following errors for fstrim.

Code:

# Without sudo
 fstrim: /media/memyself/Backup1: FITRIM ioctl failed: Operation not permitted
  
 # With sudo
 fstrim: /media/memyself/Backup1: the discard operation is not supported
Here is the bash

Code:

#!/bin/bash  

 # Define paths
 Backup1="/media/memyself/Backup1"
 Backup2="/media/memyself/Backup2"
 
 # Mount Backup 1
 #Note uuid is a permanent way of identifying the disks and is found using "ls -al /dev/disk/by-uuid/"
 if mount|grep $Backup1; then
   echo "Backup1 already mounted"
 else
   udisksctl mount --block-device /dev/disk/by-uuid/720c2af1-cc24-4cd3-ae6e-2a671f944487
 fi
  
 # Mount Backup2
 #Note uuid is a permanent way of identifying the disks and is found using "ls -al /dev/disk/by-uuid/"
 if mount|grep $Backup2; then
   echo "Backup2 already mounted"
 else
   udisksctl mount --block-device /dev/disk/by-uuid/6e36624a-d91c-4bd0-86d0-45bfa22fc172   
 fi
 
 # Check both drives have been successfully mounted and run fstrim and rsync
 if mount|grep $Backup1; then
   echo "ruing fstrim on Backup1"
   fstrim $Backup1                             # fstrim
   if mount|grep $Backup2; then
     # see http://www.howtogeek.com/135533/how-to-use-rsync-to-backup-your-data-on-linux/?PageSpeed=noscript
     echo "Backing up with rsync"  
     rsync -av --delete /media/memyself/Backup1/Docs/ /media/memyself/Backup2/Docs/
   else
     echo "Backup2 failed to mount"
   fi
 else
     echo "Backup1 failed to mount"
 fi
Would anybody care to shed light on what the problem is?

Thanks in advance
Irvine

- - , .

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 13 اسفند 1394 ساعت: 1:28

صفحه بندی