I am looking for a way to backup/sync the contents of a CIFS share to an external USB in Ubuntu, from the CLI. I have mounted the cifs share and also mounted the external storage USB.

I have the following directory structure on the CIFS share:

$ mount -t cifs -o username='<myusername>',password='<mypassword>' //<mycifs_ip_address>/<mycifs_share_name> /mnt/myshare $ ls /mnt/myshare BackupFiles > > 11_28_2014 > File_Today_11_16_2013.txt > File_Yesterday_07_02_2014.txt > 07_16_2015 > File_Yesterday_04_29_2015.txt > File_Tomorrow_10_12_2015.txt > File_Yesterday_07_02_2015.txt > 12_05_2016 > File_Tomorrow_06_10_2016.txt abc.pdf File_Names.csv Test.txt 

Note that 11_28_2014, 07_16_2015 and 12_05_2016 are directories.

I have the following directory structure on the external USB:

$ mount /dev/sha4 mnt/myusbback $ ls /mnt/myusbback BackupFiles > > 11_28_2014 > File_Today_11_16_2013.txt > File_Yesterday_07_02_2014.txt def_config.sh File_Output.dat Testing_doc.docx 

Additional information:

  1. I am using Ubuntu Server 16.04.1
  2. When mounting the CIFS share, I need to specify a username and password. The CIFS share has been set up to require these credentials when accessing it.

Problem:

I am looking for a way to:

  1. sense the directory structure on the CIFS share and on the external USB and create missing directories on the USB
  2. copy files from the CIFS share into appropriate folders on the USB, if they are missing from the USB
  3. Sync the BackupFiles directory (including all its sub-directories) on the CIFS share and the BackupFiles directory on the external usb storage.

In summary, I think I need a way to sync all files (including the directory and sub-directory structure) from the CIFS share onto the external USB storage.

Questions

Is there a way to do this in Ubuntu from the CLI? Will I be prompted to specify the CIFS share username and password?

6

Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy