BackupPC to the rescue – unusual way to solve permission problems.

Hello all,

It 6 am Sunday early morning, no sleep at all until now and I’m almost exhausted, this has been a great night! Let me tell you the story.

I’m doing a project 8000 miles away from home, now I’m living in Luanda, Angola (usually I live in Lisbon), and this weekend there was a party so I went, the singer wasn’t that bad, the place was crowed with nice Brazilian people (yes there are plenty of them in Luanda) and the food was great so I couldn’t wish for more, after dinner I had planned with some friends to hit a local disco,  But after 5 caipirinhas (a great Brazilian drink), I felt really bad from my stomach so I ended the night there and head back home. After a while in bed I still didn’t feel that good so I went to the laptop and thought in sorting some work things.

Now the fun part, being a bit drunk i did something like (i didn’t want to do it jut typed ENTER before the rest(someway i mistaken TAB with ENTER)):

sudo chown -R pedro:pedro /

I thought to myself… this is taking ages let me have another drink… and then i woke up but it was too late, I’m running to the lap but I have ext4 and an SSD so my entire file system had my UID and GID.

I have backups of everything I do, even the complete FS but the backups are 8000 Miles away and in Angola the best i can get in Internet access is 2Mb.

I felt a bit desperate, I say a bit so I don’t tell you I would like to drink a bottle of vodka to forget the stupidity I made, so before doing anything even more stupid went to the sofa and played angry birds on the tablet for 1 hour.

VOILÁ, I had an idea that will put my laptop running (I hoped)! I didn’t turn off the lap because I knew it was probable it wouldn’t turn on again, so i entered the command line and changed permissions on some critical files:

chown root:root /usr/bin/sudo
chown root:root /etc/sudoers
chmod u+x /usr/bin/sudo

afterwards I changed my home directory to the right permissions:

sudo chmod -R 750 /home/pedro
sudo chown -R pedro:pedro /home/pedro

With this i managed to have KDE and Firefox (although KDE was erratic)
With Firefox i managed to enter my backup server and choose the last backup I had, went to the log page (where the logs of all files are kept) and to my joy I saw i could get all the file owners and permissions from that page.
I just did a play text copy paste from the log into a file named FILE_LIST on my home folder (fortunately i also backup system files, applications, in sum…everything)
now with the list on my hand (I mean disk), i made a little script, it’s more a chain of commands but it worked well.
Here’s the command line:
nice -n -10 cat /home/pedro/FILE_LIST | cut -b 12- | tr -s " " | cut -d " " -f 2,4- | \
while read A ; do \
OWNER=`echo $A | cut -d " " -f 1 | cut -d "/" -f 1 `; \
GROUP=`echo $A | cut -d " " -f 1 | cut -d "/" -f 2` ; \
FILE=`echo $A | cut -d " " -f 2-` ; \
echo $FILE ; \
sudo chown $OWNER:$GROUP "$FILE" ; \

And here’s and excerpt of FILE_LIST:

create   755 0/0 2035616 bin/vim-normal
create d 755 0/0 3072 boot
create d 755 0/0 1024 boot/grub

For now I’m safe and a have my system up and running.
I knew that drinking and driving wasn’t safe, but now I know drinking and sudo should be avoid too 🙂
I’m going to bed! This all thing took 3 hours + 1 of angry birds and the day is coming out.

P.S – I know the script isn’t ideal, but considering the state I’m now I fell really happy to have things working 🙂

BackupPC, RSyncd and Windows XP, Vista, Windows 7, 2003, 2008

I just copied this post from, I use it for my personal reference.

– Because it matters – –

BackupPC SetUp: with rsyncd on Windows XP without Cygwin

Posted By tak On September 8, 2007 @ 10:31 pm
BackupPC Set-UP with rsyncd on Windows XP

This page is for the Windows client. “Client” is the computer being backed up by the server.

This is an executable of ‘rsync’ (a Linux program) that is accompanied by the DLL of Cygwin (a software that allows Windows to run Linux things).

* Windows XP
* IP address
* List of folders you want backed up OR…
* List of folders you don’t want backed up
* ~15-20 min of your time
* You do not have Cygwin installed (and you will NOT).

WARNING: If you currently have Cygwin installed or are planning on getting it, these instructions may break your Cygwin software. In that case, you must either install ‘rsync’ through Cygwin. Please see the [1] other set of instructions.

1. Download the software package (zip)

Get it here! (get the ‘zip’ package)

2. Unpackage it

make a folder named ‘rsyncd’ in C:

unzip the content into C:\rysncd

3. Edit Configuration Files

1.) rsyncd.secrets file

Located at C:\rsyncd\rsyncd.secrets

The file should look like this:


Read the instructions. As it says, make sure that the last line is a new blank line. Replace ‘UUU’ with a username (no, it does not code for phenylalanine). You can just make up this username. Replace ‘PPP’ with a real password (should at least have numbers and alphabets).

2) C:\cygwin\rsyncd.conf File
Required modification:

Find the following section:
auth users = username, backuppc
hosts allow =

IMPORTANT: Make the same modifications for the variables shown at the end of the file. ie for

* hosts alow
* auth users

Optional Modifications.

By default, the backup software will back up practically everything in your ‘C:\Documents and Settings’folder. If you want to specify the folders to be backed up, find the following section and modify.
Exact DOS style path to the file or directory to be rsync accessible
path = c:/Documents and Settings
comment = Documents and Settings

Note that the slash is forward (not backward).
Also note that everything inside the specified folder will be backed up. However, you can exclude certain folders by specifying them on the config file on the server; you can let the administrator know what folders to be excluded.
Moreover, you can only specify one path here (to specify multiple paths, see below). Here is an example,

path = c:/stuff/important_stuff/really_important_stuff

The ‘comment’ should only be 1 line. It would be a good idea to write this description for future reference

Automatic Restoration – if you would like BackupPC to automatically restore files on your computer (ie the backup server has the privilege to write to your computer), then you must turn on this option (it’s off by default). If you are planning on backing up system files so that you can restore the system (not just the data), this may be a good idea.
Otherwise, you will have to download the desired files/folders from BackupPC and manually restore them.

To turn on the option, find the following section and change ‘true’ to ‘false’

read only = true

4. Change the Permission

Now we want to make the ‘resyncd.secrets’ file read-only.


To do this, right click the file and choose ‘Properties.’

Check where it says ‘Read-Only’

5. Set Up rsyncd Service

Next, set up the rsync job as a service to be started at boot-up.

Click on Start –> Run
IF YOU’R USING WINDOW7 you need to press CRTL+Shift+Enter (not just enter)
type ‘cmd’ and press enter. In the terminal,

cd \rsyncd

cygrunsrv.exe -I rsyncd -e CYGWIN=nontsec -p c:/rsyncd/rsync.exe -a ” –config=c:/rsyncd/rsyncd.conf –daemon – -no-detach”

*the second command is a long one liner. You must issue these commands without any misspelling.

To test to see if the above command was properly issued,

Go to Control Panel –> Administrative Tools –> Services

Find ‘rsync’ and click on ‘start’ to see if the service starts properly.

6. Open a Port

Finally, open a port for rsync in the firewall.
Control Panel –> Firewall –> Exceptions

* Name: rsyncd
* Port number: 873
* Type: TCP

7. Submit config files to Administrator

Now the final step is to create and submit configuration files to the administrator. file

Copy and paste the following in Notepad:

Tell BackupPC we wish to use rsyncd: requires rsync to be running as
a service/daemon on the client system

$Conf{XferMethod} = ‘rsyncd’;

Tell BackupPC which user name and password to use. This should
match the userName:password pair in the C:\rsyncd\rsyncd.secrets
file on the client.

$Conf{RsyncdUserName} = ‘username’;
$Conf{RsyncdPasswd} = ‘password’;

Tell BackupPC which share to backup. This should be the name
of the module from C:\rsyncd\rsyncd.conf on the client (the
name inside the square brackets). In the sample rsynd.conf
file the cDrive module is the entire C drive.

$Conf{RsyncShareName} = ‘cDrive’;

Link the IP address to the host name
$Conf{ClientNameAlias} = ‘XXX.XXX.XXX.XXX’;

Now change the bolded items; username and password.

For the ‘$Conf{RsyncShareName}’ item, leave it as it is if you have not done the optional modification in the ‘rsyncd.conf’ file (see above). But change it to ‘docs’ if you have.

Also change the IP address in the $Conf{ClientNameAlias} section to your IP address.
Save the above file as ‘’ where ‘clientname’ is the name of your computer.
You can find your computer name by:

Control panel –> System
Then send this file to the administrator and nicely ask them to place the configuration file on the server ASAP.

Having Multiple Directory Paths

Find the following section at the end of the ‘rsyncd.conf’ file, copy and paste it at the end of the file (so as to have duplicates of the entire section).

path = c:
comment = Entire Drive
auth users = UUU
secrets file = c:/rsyncd/rsyncd.secrets
hosts allow =
strict modes = false
read only = true
list = false

Then change the section name within the bracket (ie [cDrive]) for the newly created (pasted) section(s).
You can change it to whatever you like, but no space please.
Modify the bolded items according to the descriptions above (note that these entries are exact copies of the main section of the rsync.conf file; they just don’t have the # comments sections).
Now change the $Conf{RsyncShareName} = ‘cDrive’; section of the ‘’ file to the following format.

$Conf{RsyncShareName} = [‘cDrive’, ‘docs’, ‘name_you_made_up’, ‘another’];

Note that these entries are supposed to be the same as the names in [] in the rsync.conf file.

8. Connect & Back-up!

After you have heard back from the administrator, do the following to connect. Bookmark the address below and go to it;

Now a pop-up window will ask you for the username and password. These are the ones the administrator gave you.

You should see something similar to below:

Click on ‘Start Full Backup’ button to start your first backup. Note that this first backup will take a while. The next time you back up, it will be an ‘incremental’ backup and should only take a few minutes.
If you get any error messages, let the administrator know of that message

9. Retrieve backed-up data

To restore files / folders, simply click on ‘browse backups’ link on the left menu.

You should see a screen like the above.

Then click the checkboxes next to the files and folders you want to restore and click on ‘restore selected files.’

Once you click on ‘restore selected files,’ a screen like the below should show up. There are 3 options to what to do with the files / folders you’ve selected.

* Option 1: Direct Restore
* Option 2: Download Zip archive
* Option 3: Download Tar archive

Option 1 will write the backed up files / folders to your harddrive (if the same file is there, it will overwrite).

Option 2 and 3 will archive the files / folders and let you download the archived package as .zip or .tar respectively. This feature has other potential uses than just backup / restoration; you can access the backed up files / folders from anywhere in the world!

To do a complete system restoration, follow the same direction as above for all files & folders through [2] KNOPPIX or something equivalent.

[3] BackupPC Manual Start Page

Article printed from Because it matters:

URL to article:

URLs in this post:
[1] other set of instructions: http://taksuyama.combackuppc_winxp_cyg.html
[3] BackupPC Manual Start Page:

Using a recover CD to restore a backup made with BackupPC – BackupPC as disaster recovery

Sometimes things go wrong. We simply can’t avoid it, a simple power failure can harm your data and corrupt your system.

One of these day in a normal work day one small server I maintain add an hard disk failure (yes it’s true, it happened again for the 3rd time this month). In this system I don’t have a RAID setup so the data was lost, well no prob I thought in the end all day is on my backuppc server.

BackupPC is one of my favorite tools, it’s great to manage, easy and very flexible, I’m not going the write about using backuppc to backup data as there are plenty of docs and mailing lists out there that can give you excellent how to(s) on the subject.

Booted with OpenSuSE 11.1 DVD and selected rescue mode.

On the command prompt and using fdisk /dev/sda I partitioned the drive like the old one (both drives were sata II), but Linux is so flexible that you don’t even need to do that.

Usually I like to use a volume manager (lvm) but I was short on time and will so just created 3 partitions /sda1 (150MBfor /boot), sda2 (4GB for swap ) and sda3(100GB for /), leaving unpartitioned  the rest (400GB), I’ll be using the free space to create volumes afterwards and then move the data there.

Then formated the partitions:

mkswap /dev/sda2

mkfs.ext3 /dev/sda1

mkfs.ext3 /dev/sda3

After this I mounted the filesystems like this:

mount /dev/sda3 /mnt

created boot in /mnt – mkdir /mnt/boot

mount /dev/sda1 /mnt/boot

so now we need to get all the data in the file system… and this is the tricky part we need a ssh server to do this (we can use nfs or http download and then untar, but I still like sshd method better, it uses rsync so the transfer is really fast.)

To do this you need to set up a ssh server from a minimalistic boot system. This isn’t hard just follow the steps:

First give this machine your old ip address ex.: ifconfig eth0

Create sshd certificate, remember this certificate is just temporary so you can restore your backup.  You may delete it afterwards. To create it just type:

ssh-keygen -t rsa -f /mnt/ssh_host_rsa_key -N “”

start sshd by typing:

/usr/sbin/sshd -h /mnt/ssh_host_rsa_key

This will start up sshd with all the default options.

Now just give a password to your user root or you won’t be able to login:

passwd root

Add the backuppc public ssh key from the backup server to /root/.ssh/authorized_keys on the restore machine.

Finally accept host key on the backuppc key (you may do this by entering on the backuppc server and access the restore machine, it will ask you to had the machine key. Just accept it.) Then copy it to the backuppc user know hosts file ex.:

tail -n ~/.ssh/known_hosts >> ~backuppc/.ssh/known_hosts

Finally your done. If you find this large and complicated don’t think it’s like that, by now you may have configured and entire ssh daemon by hand.

Go to the BackupPC console, choose your host, select the backup you want and just press restore.

On the method choose rsync but on the destination dir choose /mnt. Go out and take a coffe the restore can take a while. After it’s done all you need is to reconfigure grub and maybe /etc/fstab.

Now that the restore is done just check if /mnt/etc/fstab reflects the partition scheme, change accordantly if it doesn’t.

Finally we need to setup grub edit /mnt/boot/grub/menu.lst and check if your root partition is on the right place.

Before you can run grub-install you need to mount 2 special partitions /dev and /proc, how do you do this on a mounted and running system? The answer:

mkdir /mnt/proc; mkdir /mnt/dev; mkdir /dev/sys

mount -o bind /proc /mnt/proc

mount -o bind /dev /mnt/dev

chroot /mnt

and finally the last command:

grub-install /dev/sda

if you got and ok just reboot your system, don’t forget to eject the dvd before system boots again.

I think this was my largest post, hope you find it useful


Pedro Oliveira

Click to access the login or register cheese