Running ubuntu 16.04
Update: I got past the error messages by double quoting the variables:
cp -ru "$line" "$destname"
But it's still not copying anything. After adding echo $?
after the line above, I get 0.
Replacing cp
with ls -l
lists contents of the directories.
The code:
[ $# -eq 0 ] && { echo "Usage: $0 m/d/yyyy"; exit 1; }
DestDir=/media/WD_NAS_LEW/grsync
find Documents -type f -newermt $1 > mybackup.log
awk 'BEGIN{FS=OFS="/"}{NF--; print}' mybackup.log | while read line
do
destname=$DestDir/$line
cp -ru $line $destname
done
#rm mybackup.log
echo Done
Script output -- and the files aren't copied for lines without the errors below:
$ ./mybackup.sh 8/20/2018
cp: target 'Card/Documents' is not a directory
cp: target 'Lessons' is not a directory
cp: target 'Lessons' is not a directory
cp: target 'Letters' is not a directory
cp: target 'Asia' is not a directory
cp: target 'Procedures' is not a directory
Done
Inputs: contents of mybackup.log (full path with file name):
Documents/Phone/Phone Main Memory Card/Documents/misc.doc
Documents/Lew/PFinc/Bills N Balances.ods
Documents/Lew/Trading/Market Review.odt
Documents/Lew/Trading/Trade Tools.ods
Documents/Lew/Trading/Studies & Lessons/Summary Technical Analysis.odt
Documents/Lew/Trading/Studies & Lessons/Paper calendars and diagonals.odt
Documents/Lew/Trading/Paper Trades.ods
Documents/Lew/Trading/DVL/thinkscript/Mark_Volume_SpikeSTUDY.ts
Documents/Lew/General/Essays & Letters/0 RFR.odt
Documents/Lew/General/Long Fist et al Asia/Long Tai Chi.odt
Documents/Lew/General/Technology/Backup Procedures/find files since X for manual backup.png
Documents/Kids/Carey/Carey August 2018.odt
Documents/Kids/Renee/birth certif and social Stella.pdf
Documents/Kids/Renee/Noah/Noah Confucius tenets.odt
awk output (source dir only, no trailing "/"; destination drive is Western Digital mybook NAS):
/media/WD_NAS_LEW/grsync/Documents/Phone/Phone Main Memory Card/Documents
/media/WD_NAS_LEW/grsync/Documents/Lew/PFinc
/media/WD_NAS_LEW/grsync/Documents/Lew/Trading
/media/WD_NAS_LEW/grsync/Documents/Lew/Trading
/media/WD_NAS_LEW/grsync/Documents/Lew/Trading/Studies & Lessons
/media/WD_NAS_LEW/grsync/Documents/Lew/Trading/Studies & Lessons
/media/WD_NAS_LEW/grsync/Documents/Lew/Trading
/media/WD_NAS_LEW/grsync/Documents/Lew/Trading/DVL/thinkscript
/media/WD_NAS_LEW/grsync/Documents/Lew/General/Essays & Letters
/media/WD_NAS_LEW/grsync/Documents/Lew/General/Long Fist et al Asia
/media/WD_NAS_LEW/grsync/Documents/Lew/General/Technology/Backup Procedures
/media/WD_NAS_LEW/grsync/Documents/Kids/Carey
/media/WD_NAS_LEW/grsync/Documents/Kids/Renee
/media/WD_NAS_LEW/grsync/Documents/Kids/Renee/Noah
It seems to be changing the field delimiter. Do I need to take out spaces in dir names, or there a way to leave them?
grsync
butrsync
has worked flawlessly for me. – WinEunuuchs2Unix Aug 26 '18 at 02:26grsync
. You haven't had much luck with it huh?: https://askubuntu.com/questions/1020393/arrgh-grsync-not-working-again – WinEunuuchs2Unix Aug 26 '18 at 22:54