10

Pardon my ignorance, I am a new user of this site, Linux, and the Raspberry Pi.

The following is a link to a question, from which I used user goldilocks' well documented answer of using rsync, to create my own rsync command to make a backup to a folder on the HDD of a MacBook Pro on my local network:

Can a Raspberry Pi be used to create a backup of itself?

I was unable to follow up on this question and unable to message the user goldilocks because it seems that there is no such thing on Stack Exchange?

What I came up with is this:

rsync -aHv --rsync-path="sudo rsync" --delete-during --exclude-from=/Users/user/Documents/rsync-exclude.txt --rsh="ssh" user@host:/ /Users/user/Desktop/rpi-backup/

From what I understand the addition of the --rsync-path="sudo rsync" argument allows for not having to use an (insecure) root account over ssh.

All seems to go well but unfortunately I get an error at the end of the transfer which looks like this:

rsync error: some files could not be transferred (code 23) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-47/rsync/main.c(1400) [generator=2.6.9]

Is this something I should be worried about and if so how do I fix it? Or, is this because I used a rsync-exluded.txt file to exclude certain directories from being copied over during the rsync and this error is just confirming this?

Also, it was said by a user who replied to this question that it wouldn't be possible to backup to a Mac? My command seemed to work without problems as there was obviously a backup of the filesystem in the folder which I designated as the destination. The only hitch was the error that I received at the end of the rsync.

chaoticslacker
  • 347
  • 1
  • 2
  • 12
  • Welcome to the Stack Exchange (and the Raspberry Pi flavoured corner of it)! Whilst you cannot send messages to a particular user if you participate in (initially) asking good questions and providing good answers your reputation will increase to the point where you can talk in the chat rooms (20+ reputation) and add comments to material that is not your own (50+). – SlySven Feb 22 '16 at 00:14
  • The user "goldilocks" is currently one of our moderators (note the ♦ next to their name) and as such is quite active - you may well find him in "The Bakery" which is the primary chat room for the Raspberry Pi SE... Oh, and have a +1 for a reasonable question to help you on your way. 8-) – SlySven Feb 22 '16 at 00:17
  • The link you quoted has many different variants. I routinely use one of these (to backup to HDD). You should specify where you are attempting to backup to. Unfortunately, if you are trying to backup to OS X you will not succeed, for many different reasons. You can backuk to another Linux machine. – Milliways Feb 22 '16 at 00:38
  • Thank you for the warm welcome SlySven! Hopefully I'll get enough points to get into this chatroom eventually! Milliways, could you please explain why it is that you said I will not succeed in backing up to OS X or possibly point me to somewhere , where this statement is a bit more fleshed out? – chaoticslacker Feb 22 '16 at 01:14
  • If you are referring to a comment you should address it (with @). 1 The Unix and Linux rsync differ, 2 OS X overlays Unix with its own layer which prevent access to certain directories 3 Unless Users match settings may be lost, 4 Permissions on hfx and ext4 differ significantly. You may be successful in backing up user files, but system files will be lost/lose permissions. – Milliways Feb 22 '16 at 02:18
  • @Milliways , Thank you for the explanation. It does seem impossible to back "everything" up to an OS X machine as this same command with identical arguments worked FLAWLESSLY on a dedicated Linux box. I really would hate to give up on this working with OS X and am really disappointed that there isn't some work around. – chaoticslacker Feb 22 '16 at 22:29
  • I wasted considerable time trying to get it going (admittedly over a year ago on an older OS X). In the end it was easier to use an old HDD. I do use the Mac to make security backup images of the SD card (before updates). – Milliways Feb 22 '16 at 22:35
  • Please consider accepting one of the answers or leaving a comment if they didn't help you. – Dmitry Grigoryev Sep 27 '16 at 11:46

2 Answers2

1

There are several problems with doing what you are trying to do.

  1. As others pointed out, you lose a lot of metadata going from ext[234]fs to hfs+ and back. Also, by default hfs+ is case-preserving but case-insensitive, so if you have, e.g, /bin/foo and /bin/Foo, you'll lose one of them. Better use another linux machine. In the extremely unlikely case that you don't have a spare machine, just bring up a linux VM on your macbook.
  2. the rsync options are not wrong. You need -avSHxAX to correctly transfer all metadata.
  3. You don't really need --rsync-path or --rsh. Just do what you are doing as root, and set up .ssh/authorized_keys on the other machine's root account to allow access. Less confusing.
  4. The right way to take backups is to use dump/restore.
JayEye
  • 1,898
  • 11
  • 18
1

I've been using rpi-clone every day for a few weeks to clone my running RPi3 running Raspian Jessie. It takes about 10 minutes to clone to a second Micro SD card. I then switch off, take out both cards, store the original and boot using the clone. Hence I know that the backup works. I rotate 3 cards in this way, so that I always have a safe card. It works for me ;-)

Geoff
  • 194
  • 6
  • Interesting script Geoff, unfortunately I don't have the needed hardware at the moment to check it out. Will be checking it out soon though. Thanks for the link. – chaoticslacker Apr 25 '16 at 11:06
  • @chaoticslacker, The latest version of rpi-clone is now 2.0.22 (works for Buster). Wondering if you'd like to Select my Answer? – Geoff Jul 21 '20 at 06:19