0

I'm about to make a copy of a website (templates)

Would it be possible to make symlinks, so changes in the original is reflected in the copy, but if I edit the copy, the symlink is replaced with the new version, and the original remains the same?

The filesystem is ext3.

The editor reads and writes over ssh

Lenne
  • 987
  • 1
  • 13
  • 32

2 Answers2

0

Short answer: no, it is not possible to enforce a similar behavior. You must take a full backup of your website and be ready to restore in case problems arise.

Long answer: Actually, some editors enforces a similar behavior. Basically, they never write a file directly; rather, they use a random filename and atomically rename it to the correct name. To be clearer:

  • you open the symlink and the editor loads its content
  • when saving, the editor save a file with a random name as "abcdef.txt"
  • after that, the random-name file is rename to the correct name, which implies the deletion of the symlink (without altering its content)
  • you will end with a new standard file and a deleted symlink, with the original file remaining in-place, unmodified, in its own location.

That said, I will absolutely not count on this behavior: other editors (eg: vim) do in-place saves, and so they will change the symlink content. Please do a full backup of all the files you intend to change, and be ready to restore if something goes wrong.

shodanshok
  • 47,711
  • 7
  • 111
  • 180
0

Consider using a version control system. You will have a duplicate copy of the files, but you can have them on any system you want. It will make identifying changes much easier, and provide a large number of additional benefits. See my answer on version control for a web site for more details.

If you want to use links, consider hard links. Depending on the the editor hard links will be replaced with a new file. If they create a new file and rename it into place, the hard link will be broken. The first backup copy will be the hard linked version. You will be able to identify changed files by link count.

BillThor
  • 27,737
  • 3
  • 37
  • 69