Search code examples
macosrsyncrobocopycp

rsync copy for a lots of different types of extensions


I'm trying to copy all of the mac files to usb external drive. The purpose is, I need to copy specific types of file for internal investigation.

The Equivalent Robocopy command on Windows will be like this

Robocopy C:\ D:\Company\Dept.\username /S /DCOPY:T /TEE /R:1 /W:1 /NP /FP /V /TS /NDL 
/BYTES /Log:D:\Company_Dept_userame.Log  *.doc *.ppt *.xls *.docx *.pptx *.xlsx *.pdf 
*.gul *.hst *.db *.dbf *.dzw *.dzi *.dbs *.mdb *.accdb *.pst *.eml *.msg *.edb *.dbx 
*.ost *.mbox *.zip *.ace *.arj *.cab *.egg *.7z *.enc *.alz /XD Dirs "Documents and Settings" "Application Data" 

it's pretty simple, copy the target file types from the entire OS disk to the external drive and make a log for this file copy.

But, for MacOS, I couldnt't make it using Rsync or using the CP. it just doesn't work for me making file path errors and I couldn't find any answers I could use neither.

Can anyone please help me to solve this issue? Manual copying is such a pain.

Thank you, Steve


Solution

  • I didnt want to post an answer to my question but just wanted share and hope there shouldn't be no more stupid like me.

    I found the reason. I was running the source path as absolute path. I needed to cd to the root, which is Macintosh HD by

    cd /

    and then run the rsync command. In my case, I'm copying all of my OS disk specifying a lots of extensions to the external disk so I ticked -aPcx which means archive,skip checksum, exclude other disks.

    especially 'x' option is important otherwise you'll get a copy of USB disk itself to the destination folder.

    rsync -aPcx --prune-empty-dirs --log-file=/Volumes/SSD/Company_Dept_username.log --include=*/ --include=*.{hwp,doc,ppt,xls,docx,pptx,xlsx,pdf,gul,hst,db,dbf,dzw,dzi,dbs,mdb,accdb,pst,eml,msg,edb,dbx,ost,mbox,zip,ace,arj,cab,egg,7z,enc,alz} --exclude=* . /Volumes/SSD/Company/Dept/username