deleting files with rsync

To delete files that are on the destination system but no longer on the source system, use the –delete option:

[root@server:~/tmp]# ls -ls
total 0
0 -rw-r--r-- 1 root root 0 2008-10-01 11:18 1
0 -rw-r--r-- 1 root root 0 2008-10-01 11:18 2
0 -rw-r--r-- 1 root root 0 2008-10-01 11:18 3
[root@server:~/tmp]# ls -ls /tmp/b
total 0
[root@server:~/tmp]#  rsync -azv  /root/tmp/ /tmp/b
sending incremental file list
./
1
2
3

sent 163 bytes  received 72 bytes  470.00 bytes/sec
total size is 0  speedup is 0.00
[root@server:~/tmp]# ls -ls /tmp/b
total 0
0 -rw-r--r-- 1 root root 0 2008-10-01 11:18 1
0 -rw-r--r-- 1 root root 0 2008-10-01 11:18 2
0 -rw-r--r-- 1 root root 0 2008-10-01 11:18 3
[root@server:~/tmp]# rm 2
[root@server:~/tmp]# ls -ls
total 0
0 -rw-r--r-- 1 root root 0 2008-10-01 11:18 1
0 -rw-r--r-- 1 root root 0 2008-10-01 11:18 3
[root@server:~/tmp]# ls -ls /tmp/b
total 0
0 -rw-r--r-- 1 root root 0 2008-10-01 11:18 1
0 -rw-r--r-- 1 root root 0 2008-10-01 11:18 2
0 -rw-r--r-- 1 root root 0 2008-10-01 11:18 3
[root@server:~/tmp]#  rsync -azv  --delete /root/tmp/ /tmp/b
sending incremental file list
./
deleting 2

sent 53 bytes  received 15 bytes  136.00 bytes/sec
total size is 0  speedup is 0.00
[root@server:~/tmp]# ls -ls /tmp/b
total 0
0 -rw-r--r-- 1 root root 0 2008-10-01 11:18 1
0 -rw-r--r-- 1 root root 0 2008-10-01 11:18 3
[root@server:~/tmp]#
Advertisements

Tags:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: