Move directory with rsync and delete from source

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Move directory with rsync and delete from source
# 1  
Old 05-19-2017
Move directory with rsync and delete from source

I need a rsync command which will exclude certain files and directories from source and copy the rest. I got this command working,

Code:
sudo rsync -avzh --exclude 'bin' --exclude 'braintree' --exclude 'colinmollenhour' --exclude 'composer' --exclude 'doctrine' --exclude 'fabpot' --exclude 'justinrainbow' --exclude 'league' --exclude 'lusitanian' --exclude 'magento' --exclude 'monolog' --exclude 'oyejorge' --exclude 'pdepend'  --exclude 'pelago' --exclude 'phpmd' --exclude 'phpseclib' --exclude 'phpunit' --exclude 'psr' --exclude 'sebastian' --exclude 'seld'  --exclude 'sjparkinson'  --exclude 'squizlabs'  --exclude 'symfony'  --exclude 'tedivm'  --exclude 'theseer' --exclude 'tubalmartin' --exclude 'zendframework' --exclude 'autoload.php' /var/www/html/magento2/vendor/ /var/www/html/magento2/app/code/

Now this works fine. It does copy everything other than excluded directories but i want this to delete the copied files from source location too. Please advise.

Regards,
Siddhesh
# 2  
Old 05-19-2017
Does your rsync version offer the
Quote:
--remove-source-files sender removes synchronized files (non-dir)
option? If not, log to a file, and create a removal script from the log.
# 3  
Old 05-20-2017
HI,

--remove-source-files is only applicable for files. I need to remove directories too.

-S
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Rsync and Move files

I Have a requirement where i have to sync two directories one on source location server A and other on destination location server B as i do not have ssh access from server A----------->B I am doing rsync from server B, The Requirement is as follows Two directories on the source and... (4 Replies)
Discussion started by: James0806
4 Replies

2. Shell Programming and Scripting

Rsync Error: rsync: link_stat failed: No such file or directory (2)

I wish to copy all the files & folder under /web/Transfer_Files/data/ on mymac1 (Linux) to remote server mybank.intra.com (Solaris 10) /tmp/ location I am using Ansible tool synchronize module which triggers the unix rsync command as below:rsync --delay-updates -F --compress --archive --rsh=ssh... (2 Replies)
Discussion started by: mohtashims
2 Replies

3. Shell Programming and Scripting

Move directory recursive and leave symlinks at source

Looking for a script or command to - Move a very large directory with tens of thousands of files and sub-directories recursively (filenames can include spaces) and replace with symlinks pointing to the new location at the same time so there is no downtime Looking for speed + safety :o (5 Replies)
Discussion started by: carnagel
5 Replies

4. UNIX for Advanced & Expert Users

Rsync with --delete but do not delete peer dirs on target

rsync with --delete won't honor the delete if the source is something/*. I want the delete to work, but not to delete directories on the target that are peer to the intended directory. For example, using these source and target file structures: Source on desktop: ~/ Money/ ... (4 Replies)
Discussion started by: JavaMeister
4 Replies

5. UNIX for Dummies Questions & Answers

How to move gz files from one source directory to destination directory?

Hi All, Daily i am doing the house keeping in one of my server and manually moving the files which were older than 90 days and moving to destination folder. using the find command . Could you please assist me how to put the automation using the shell script . ... (11 Replies)
Discussion started by: venkat918
11 Replies

6. Shell Programming and Scripting

Rsync move with symlinks

Hi, I use rsync to move from source to target, but there are cases that I need to exclude: Suppose in my file system, I have a soft link ~/data -> /media/volgrp/data. Under data folder, there is a file hello.txt. After moving command "rsync --remove-source-files -aH --force ~/data/... (3 Replies)
Discussion started by: huangyingw
3 Replies

7. Shell Programming and Scripting

Move all files from source to destination directory based on the filename

Move all files starting with a specific name to different directory. This shell script program should have three parameters File Name Source Directory Destination Directory User should be able to enter ‘AB_CD*' in file name parameter. In this case all the files starting with AB_CD will... (1 Reply)
Discussion started by: chetancrsp18
1 Replies

8. UNIX for Advanced & Expert Users

Why rsync deletes source directory?

Hi I have a strange problem. Sometimes when I execute the below command something wierd happens. rsync -avz -e ssh travegre@travegre.net: ../travegre.net/ the folder named "hm" that is held in travegre.net and is coppied along with all the other folders and data at travegre.net, gets... (1 Reply)
Discussion started by: travegre
1 Replies

9. Shell Programming and Scripting

Rsync help - unable to delete the Source file

Hi All, I am facing problem deleting Source while using the rsync command. rsync --include=*`date --date="-1 day" \+\%Y\%m\%d`* --include=*`date +\%Y\%m\%d`* --exclude=* --delete-after -auvb -e ssh USER@SERVER:SOURCE DESTINATION However the sync happens but not the deletion of the source... (1 Reply)
Discussion started by: amitkhiare
1 Replies

10. Shell Programming and Scripting

Bash rsync but move not delete

There might be an easy solution to my problem, or maybe not, but here it is. I am trying to rsync a Volume with 1.5 terabytes of data and send it via fibre channel to a raid array. Now normally when I rsync it scans through everything and, before copying anything, deletes any files that have... (1 Reply)
Discussion started by: Movomito
1 Replies
Login or Register to Ask a Question