Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

One way to help back up personalized system files System
It seems like every time I backup my home folder and then do an erase and install, I forget a bunch of system files: my hosts file, apache, mysql, and php config files. So I've come up with a handy solution. I've created a folder in my home folder, ~/.system. In that folder, I've created hard links to a bunch of system files:
hosts -> /etc/hosts
httpd.conf -> /etc/httpd/httpd.conf
my.cnf -> /etc/my.conf
sites.conf -> /etc/httt/sites.conf
You create a hard link in Terminal using this syntax, assuming you're in the directory where you'd like the link to be created:
$ cd ~/.system
$ ln /etc/hosts .
A hard link creates two directory entries pointing to the same file on the disk. Deleting one directory entry doesn't delete the file. Now when I back up my home folder, I also back up these personalized system files.
    •    
  • Currently 2.50 / 5
  You rated: 1 / 5 (4 votes cast)
 
[6,009 views]  

One way to help back up personalized system files | 4 comments | Create New Account
Click here to return to the 'One way to help back up personalized system files' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
One way to help back up personalized system files
Authored by: rflorence on Mar 29, '07 08:29:33AM

You might want to add that this scheme will only work on systems which have the system files and home directories on the same partition -- which is Apple's default scheme, but is always the setup. Hard links do not work across partitions.

- Ronald Florence



[ Reply to This | # ]
Can Finder identify a hard link? And a caution.
Authored by: MtnBiker on Mar 29, '07 10:40:29AM

If this works the way I think it does, it provides easy access to those files too.

But as far as I can tell, in the Finder the hard link looks like a stand alone file (Info shows nothing unusual, icon is the same as the original). Which could lead one to making changes in what looks like a copy, but is an important system file.

Is there a way to tell in the Finder that it's a hard link?
--------
The Finder gets very confused if you edit the hard link. The original can temporarily disappear from the Finder. And my limited test shows that the original is unchanged (and maybe delinked) if you edit the hard linked version. In fact it seems that the original file loses changes made to it if you later make changes in the hard link.

From this I take away, do not make any changes in the hard linked file. But since there is no way of knowing that you are working on the hard linked file, that's not easy to prevent.

I can easily imagine working on the hard link instead of the original: If you create a hard link, check the hard link to make sure it looks good, and then using "open recent" in a text editor, work on the hard link instead of the original file.

I hope I'm wrong about this or that there is a simple work around.

---
Hermosa Beach, CA USA



[ Reply to This | # ]
One way to help back up personalized system files
Authored by: ccase on Mar 29, '07 12:27:26PM

Just back up the whole of /etc (/private/etc) when you back up your home directory. Mine is only 3 MB. Then you won't have any worries about forgetting a file, or about it becoming unlinked from your backed up version when you edit the original.

If you only want to back up one directory, make a link from your home to /etc and make sure your backup tool copies the contents of /etc.



[ Reply to This | # ]
One way to help back up personalized system files
Authored by: dhosek on Mar 30, '07 05:08:54PM

There's no reason to use hard links. Symbolic links work just as well and don't have the difficulty. Just do ln -s rather than ln. It's become kind of second-nature for me to type ln-s whenever I create a link. It shows up in the finder as if it's a linked file (which it is). Note that finder links are not symbolic links and can't be treated as if they're the same file from the shell or low-level commands.



[ Reply to This | # ]