Find the answer to your Linux question:
Results 1 to 6 of 6
Hi, I was trying to write a script that allows an incremental back up on Ubuntu Server 10.04. It's a very simple script that uses rsync. I am doing an ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2010
    Posts
    9

    same files get duplicated after rsync


    Hi,

    I was trying to write a script that allows an incremental back up on Ubuntu Server 10.04. It's a very simple script that uses rsync.

    I am doing an experiment to see how rsync works. it really impressed me. It works for me. However, I found something strange but I think this has to do with the permission and file owner.

    I have a folder called "important notes" that I have a copy on my external hard drive and another copy on the server. In my experiment, when I run the script. The rsync did copy everything from the external HD to my server. But instead of overwritting the old one with the new one, I saw duplications everywhere.

    for example:
    rwxrwxrwx 1 user1 user1 ... file1.bak
    rwxr-xr-x 1 root root ... file1.bak~

    Does this mean that I have to manually set the permission from 755 to 777 (for root) before the script is run. What's the best practice here?

    Any help would be greatly appreciated.

    Thank you

  2. #2
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    626
    Not sure what permissions you are passing to your client or server. I know there a way to make rsync make copies, but to create backups on the other end, which sounds like that's what is happening. So I'd check your client side settings first off.

    Secondly, if you are running rsync as root, then you should be ashamed of yourself as its a major no-no. Check your server configs (I use /etc/rsyncd.conf):
    Code:
    uid = nobody
    gid = users
    ...(some other configs)
    incoming chmod = Du=rwx,Dgo=rx,Fu=rw,Fg=rw,Fo=r
    the incoming chmod controls what bits are set for files and directories. D = directory, F = file, u = user, g = group, o = other

    For each rsync module, you can set different uids,gids, and masks.
    linux user # 503963

  3. #3
    Linux User ptkobe's Avatar
    Join Date
    Feb 2008
    Location
    Torres Vedras, PT
    Posts
    276
    file1.bak~ is not the same as file1.bak, right?

    That just means you have edited file1.bak owned by root as user1, with an editor that created a file1.bak~ file as a backup, and rsync is backing it up also, as it should. No?

    backup the backup file file1.bak~, the backup file of file1.bak... lovely.
    Regards~
    Luis

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    626
    Quote Originally Posted by ptkobe View Post
    file1.bak~ is not the same as file1.bak, right?

    That just means you have edited file1.bak owned by root as user1, with an editor that created a file1.bak~ file as a backup, and rsync is backing it up also, as it should. No?

    backup the backup file file1.bak~, the backup file of file1.bak... lovely.
    Regards~
    Luis
    looks like the original file is owned by user1. the backup is owned by root. If this created after using vim or something, you may have "set backup" turned on in VIM. I've also seen kwrite and kate (KDE programs) do the same thing.

    Are you maybe using a -b in your rsync command?

    rsync - Linux Command - Unix Command
    linux user # 503963

  6. #5
    Just Joined!
    Join Date
    Mar 2010
    Posts
    9
    Quote Originally Posted by scathefire View Post
    looks like the original file is owned by user1. the backup is owned by root. If this created after using vim or something, you may have "set backup" turned on in VIM. I've also seen kwrite and kate (KDE programs) do the same thing.

    Are you maybe using a -b in your rsync command?
    Thanks Scathefire and Luis for your replies.

    Yes, the answer is yes - I used -b switch in rsync.

    rsync -ab source destination

    Then, I use rsync -avv source destination.

    Many thanks

  7. #6
    Linux User ptkobe's Avatar
    Join Date
    Feb 2008
    Location
    Torres Vedras, PT
    Posts
    276
    Oh, so it was the -b option that was creating the ~ files on the destination, right? Well done, scathefire.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •