How to rsync a linux server to a local directory excluding all os files

269 views Asked by At

I wanted to backup an aws machine and exclude os files, only user files including root owned ones which need sudo permission to read.

1

There are 1 answers

0
Jahan Zinedine On BEST ANSWER
rsync -aAXv --rsync-path="sudo rsync" -e ssh \
--exclude={"/swapfile","/var/lib/*","/var/cache/*","/usr/*","/sbin/*","/lib/*","/home/admin/go/*","/home/admin/downloads/*","/home/admin/.sdkman/*","/home/admin/.oh-my-zsh/*","home/admin/.rbenv/*","home/admin/.nvm/*","/home/admin/.npm/*","/home/admin/.m2/*","/home/admin/.gvm/*","/home/admin/.cache/*","/dev/*","/boot/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} \
 [email protected]:/ \
~/aws_machine


-e ssh: specifies that the rsync command should use the ssh protocol for the transfer.
--rsync-path="sudo rsync" fixes the permission denied for non-user owned files and folders