Chandana
Chandana

Reputation: 2638

Restore Deleted folder from SVN

In my SVN folder someone deleted our project source code. Using SVN history we are unable to identify person who deleted those files. Project related none of the activity shown under history.

  1. is there any option to delete a folder from SVN without log in history?
  2. is there any option under SVN server to recover those files?

Thanks

Upvotes: 0

Views: 5186

Answers (6)

Praveen-K
Praveen-K

Reputation: 3401

You can check with the svn log to see other's activity on svn repo.

If some one have removed from server itself then you are screwed, you should take the backup of that repository on some shcedule. well no problem, in your team some one would not have update from server so he/she might be having that deleted files.

you can recover with

svn up -r <with-older-version>.

Personally i hate CVCS system, i would prefer to use DVCS.

But in my organization, i am forced to use CVCS. :(

Upvotes: 0

&#193;lvaro Gonz&#225;lez
&#193;lvaro Gonz&#225;lez

Reputation: 146350

All deletions will show up in the log unless the repo is seriously mangled. My guess is that you are querying the wrong path, possibly by issuing svn log from a working copy. The subcommand accepts a URL so you can simply:

svn log https://example.com/svn/project/

instead of

svn log 

... or:

svn log https://example.com/svn/project/trunk/

Of course, if you know the directory path and know a revision number where it still existed, you can simply:

svn log https://example.com/svn/project/trunk/foo/bar@314 --revision 314:HEAD

Update: Despite Lazy Badger's surprising claims, revision history is a core feature of Subversion and does not depend on the repository access method:

E:\test>svnadmin create myrepo

E:\test>svn checkout file:///E:/test/myrepo mywc
Checked out revision 0.

E:\test>svn mkdir mywc\mydirectory
A         mywc\mydirectory

E:\test>svn commit -m "Add a directory" mywc
Adding         mywc\mydirectory

Committed revision 1.

E:\test>svn delete mywc\mydirectory
D         mywc\mydirectory

E:\test>svn commit -m "Remove the directory" mywc
Deleting       mywc\mydirectory

Committed revision 2.

E:\test>svn log -r2 -v file:///E:/test/myrepo/
------------------------------------------------------------------------
r2 | ALVARO.GONZALEZ | 2012-04-03 17:00:34 +0200 (mar, 03 abr 2012) | 1 line
Changed paths:
   D /mydirectory

Remove the directory
------------------------------------------------------------------------

E:\test>

And it makes sense: not being able to track changes would render Subversion totally useless as version control tool. The commenter is probably confusing the log in svn log with the access log maintained by Apache, which is an entirely different thing and cannot even be read though Subversion commands.

Any deletion committed to the repository will show up in the revision log, no matter how it was committed, unless (I as I already pointed out) the repository itself has been damaged.

Upvotes: 4

Lazy Badger
Lazy Badger

Reputation: 97270

is there any option to delete a folder from SVN without log in history?

Sadly, yes - using file:/// protocol for accessing repo without any authentication

is there any option under SVN server to recover those files?

Yes. You can, using any accessible svn-tools, find latest revision, there this folder still exist, and update only this folder-in-question in local Working Copy to this revision (you'll get "sparse working copy" as result). Commit this state of WC as new revision and all must be fixed after it (while next incident will not happens again)

Note: svn copy solution is also viable

Upvotes: -2

mliebelt
mliebelt

Reputation: 15525

My 2 cents:

  1. No.
  2. Just copy back the state on the repository before the deletion. So look at the example below. If you do the following command, the deleted folder /trunk/src/my/proj/client should be restored: svn copy http://my.company.com/svn/repo/trunk/src/my/proj/client@4710 http://my.company.com/svn/repo/trunk/src/my/proj/

Example repository with file structure:

    Repo: http://my.company.com/svn/repo/
    /trunk
      /src
         /my
           /proj
               /server
               /client (is deleted on revision 4711)

Upvotes: 1

William Leara
William Leara

Reputation: 10687

  1. No, there is no way to delete a folder without it being reflected in the SVN log. An administrator with access to the SVN server could perhaps do a SVNADMIN DUMP/SVNADMIN LOAD and use SVNDUMPFILTER to remove a changeset, but I don't think that's what you're asking... or is it possible that is what happened?

  2. The SVN repository can be rolled back to any previous revision and so there is no change that cannot be undone. If you're certain that a folder was deleted without it being reflected in the SVN log, then maybe someone has a working copy that still contains the folder -- you could get it from there.

Upvotes: 1

Attila
Attila

Reputation: 28762

The only way I can think of deleting from SVN without it showing up in the log if the delete happened behind the back of the SVN service (e.g. someone logged in to the server and deleted the files/directory from the command shell).

If this is the case, you could restore the files/directories from a backup made on the server -- assuming the server was backed up. Note that in this case you will most likely have access to an earlier version of the source (when the backup was made), depending on how recently people committed to that directory.

OF course, if the delete happend as described above, it mostr likely messed up the SVN bookkeeping, so you might have trouble committing...

Upvotes: 1

Related Questions