Archive for the ‘rsync’ Category

deleting files with rsync

October 1, 2008

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]#