Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My colleague and I have been struggling with deleting a directory and its contents.

We are working on a new version of our websites source code on Ubuntu 8.04 (dir: /var/www/websites), what we want to do is delete the websites directory and recreate it from a .tar backup we created a couple weeks ago. The purpose of this is so we can run our deployment procedure in a local environment before we do so on our live / public environment.

We use this command:

rm -r websites

This deletes the directory and the files within it.

The problem occurs when we un-tar our backup file and view the website we are getting files that don't exist in the .tar backup, in fact these files were only created a few days ago and should have been deleted.

We delete the directory once more in the manner stated above, we then create a new websites directory using the mkdir command. Strangely at this stage the 'deleted files' do not come back, but if we unpack our .tar file the 'deleted files' appear again.

Is there a way to ensure these files are deleted, or at least the pointers that associate them with said directory.

  • Our .tar backup does not include these files
  • We do not want to use the shred command
  • We do not want to use 3rd party applications
  • Solution should be functional via terminal (SSH)

Many thanks!

EDIT

Er... we fixed it. Turns out the files that are reappearing are because of a link we have to another directory (outside the /var/www/websites), we were restoring the link but not deleting the files on the other end. D'oh!

Many thanks for your help guys... friday afternoon syndrome :-)

share|improve this question

3 Answers 3

I think something is either recreating the files, and you have to identify that (check the cron log maybe?), or the files really are in your tar file.

To check if it is in the tar file:

tar tvf tarfile.tar | grep 'nameOfReappearingFile'
tar tvzf tarfile.tar.gz | grep 'nameOfReappearingFile'
tar tzjf tarfile.tar.bz2 | grep 'nameOfReappearingFile'

To hunt for cron jobs, see this Serverfault Post: How to View All Cron Jobs On Linux?. You could also run top to watch if there any processes when you see the files start to be recreated.

share|improve this answer
1  
Problem solved, see original post for humiliating explanation :D –  Ben Everard Dec 11 '09 at 16:35

It sounds like the tar file does include those files. If you are actually removing the directory, ie after you do the rm then "ls websites" shows that it's been deleted, then the files must be in the tar file.

tar tvf tarfile

Will list the contents of the tarfile without extracting anything.

share|improve this answer
1  
Add a z switch to that command if .gz, or a j if .bz. –  Kyle Brandt Dec 11 '09 at 16:24
    
Problem solved, see original post for humiliating explanation :D –  Ben Everard Dec 11 '09 at 16:35
up vote 0 down vote accepted

The problem was a sym-link that none of use were intelligent enough to spot.

Not to worry :-)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.