i have arch setup and i am using smbnetfs to mount some windows shares in /mnt/smbnet
what i want to do is copy files from my home dir to a dir in /mnt/smbnet but i also need it to remove files if i have deleted them from my home dir
seems that cp would be the easiest for me, but i cant get it to remove a file from the dest that has been deleted from the source
example, i can do this as root
and it does copy files. and if i add a file, it copies the new one over. but if i delete a file and run this command, the deleted file does not get removed from /mnt/smbnet
didnt see anything in man cp that relates to what i am trying to do. did i miss something? is there a better way?
ok, sorry, this isnt a bash script, but i would put it in one, sorry if my title is misleading
Sounds like you are trying to syncronise to directories, the best tool for this sort of thing is rsync not cp.
You probably need something like:
Once your happy with what is going to happen remove the --dry-run to do the actual sync.
---------- Post updated at 08:57 AM ---------- Previous update was at 08:51 AM ----------
@Nevyn, Don't think compression (-z) will help here as dest filesystem is mounted via samba (compress is maily for network performance when rsync is talking to a remote rsync server). Also I included the -r flag as original cp command was doing sub-directories.
Thanks Nevyn, I always added -r with -a (Lucky I never needed to copy all the files in a directory without sub dirs, or I would have found my misunderstanding at the expense of syncing a heap of files I didn't want to!)
wow, thank you both for your input. i was going to look at rsync, but wasnt sure
couple of questions, explain how the -del or -delete works. is that the part that will remove a file from the dest if it has been removed from source? man rsync says -del and -delete are a bit different
if i have symlinks in certain directories that point to files that are being synced anyway do i still use the -l
---------- Post updated at 08:53 PM ---------- Previous update was at 08:32 PM ----------
think i answered my own questions
--ignore-existing will not sync the file if it exists on the dest, but will it check to see if the file has changed first before it skips it?
The difference between -del and -delete is just when the delete is done, helps with files that are linked to, it really comes into play on busy destination systems where directories are being monitored and the like.
Do you have links pointing outside the Videos tree?
You might be best in using --copy-unsafe-links anyway just incase a link outside the tree is created in the future.
--ignore-existing does what the description says - if file exists on the dest it's ignored (It will not change the dest file even if the timestamp/size/content/permissions are different)
The bash executes but returns no results and the set -xv showed while the $run variable in blue, was extracted correctly, the $match value in green, was not, rather both values in home/cmccabe/Desktop/f1 were extracted not just the matching.
There will always be an exact match from the $run to... (7 Replies)
hi all,
i want a program or to make a bash script to find out the total ETA/percent (would be nice aswell a progress bar) of a copy recursive command
so lets say i do -
cp -r /source_folder/ /destinatation_folder/
and when i run it i get no information on the screen of how the copy is... (20 Replies)
Hello,
Trying to get a bash for files received on daily basis and want to copy those files to different directory and send an email notification if file exists then send the file counts else Alert with no file received.
FileName format: DailyTransaction_2015-03-09_ 200.csv before 200 their is... (1 Reply)
Our Apache log files are written to a location on the server that we as clients have no access. Don't ask.
Every month, I have to e-mail the administrator to have him manually copy our Apache log files to a directory in our file space. You can probably guess how efficient it is to do things this... (3 Replies)
Hi
I have the following script to copy files from one directory to another:
#!/bin/sh
touch -mt 201304240000 /var/tmp/ref1
touch -mt 201305152359 /var/tmp/ref2
find /moneta_collected02/in_psl -type f \( -newer /var/tmp/ref1 -a ! -newer /var/tmp/ref2 \) > file_lst
cp -pr $(< file_lst)... (6 Replies)
Beginner/Intermediate shell; comfortable in the command line.
I have been looking for a solution to a backup problem. I need to compare Directory 1 to Directory 2 and copy all modified or new files/directories from Directory 1 to Directory 3. I need the directory and file structure to be... (4 Replies)
Hello,
I have written a script to copy files from one partion to another. Not sure if this is correct.
#!/bin/sh
CDR_SOURCE=/storage/archive/logmgmt/result/billing/
CDR_DEST=/storage4/archive/logmgmt/result/billing/
cp $CDR_SOURCE $CDR_DEST;
exit 0
The CDR_SOURCE folder has... (5 Replies)
Hi, I have a bunch of media files in a directory that have been converted (from MTS to MOV format), so my directory contains something like this:
clip1.mts
clip1.mov
clip2.mts
clip2.mov
The problem is that the .mov files that have been created have the timestamps of the conversion task,... (2 Replies)
Basically it's for a work assignment.
Have to make a menu with the following choices
***************menu*********************
1) Show Current Directory
2) Dispaly Current Time and Date
3) Copy
4) Change Password
5) write directory to file
6) Edit File Directory
7) Make backup from... (1 Reply)
System: Ubuntu Intrepid Ibex
I'm running webcamd as a sort of "security" program, but I need a script that will archive my webcam.jpg files.
So, take the following file:
/home/slag/www/webcam.jpg
Rename it--preferably with a time stamp.
Place it in say:
/home/slag/www/history/
... (4 Replies)