You are not logged in.
Pages: 1
Hi all,
I have a directory, "stuff" that contains four years accumulation of organized and categorized files (mp3's, writings, programs, movies, etc.). This particular directory resides in my home directory.
It occured to me that it would be very simple to accidentally type, "rm -rf stuff," it would all be over.
How can I protect that directory from being accidentally deleted by me? (without inhibiting me from moving files into it, writing to files in it, executing files in it, etc).
As the old saying goes, if you put all your eggs in one basket, watch that basket.
Russ
Offline
you can exist that directory when u are root so when you are a normal user you can't delete it.it is the simplest way.
In a world without walls,who need windows?
Offline
I would just go with the backup route. Anyone running a computer should do it anyways just because anything could happen. I back up /home, /etc and some other miscallaneous stuff everynight as a cronjob onto a separate hard drive in a tarball. Its saved me at least three or 4 times now in some shape or form in the last year.
Offline
write a wrapper "rm" script that checks the directory name before passing it on to the real "rm" binary in /bin/rm
Your rm script can just make sure the directory name isn't one of your precious folders. If it is, it just prints a warning message of some sort.
#!/bin/bash
if [ $1 = "stuff" ]; then
echo "sorry, can't rm"
exit
fi
/bin/rm $1
That's just a 5 second example I typed up. Probably want to add a $2 in there to be able to pass stuff like "-rf" too. Just alias that to be rm instead of the real rm.[/code]
Offline
Thanks for the suggestions. I like the backup solution, but I'm not going to go there just yet. The directory is too big for that. In the future (next month) I might set up a a separate machine to automatically backup for me.
I'm not sure what "exist" means, but that sounds like it might be the best solution. Could you please explain what that means?
If that doesn't work out, I'll write a wrapper (neat idea).
Thanks.
Russ
Offline
backup to a CD, also, a remote server with version control may be nice - typically server people do nightly backups. I keep all my configs on a remote server, under svn
Offline
Maybe man chattr and man lsattr will help (ext2/3 only afaics).
Offline
backup is one of the first things you should do, not one of the last. i back up /etc, /home and a mounted "media" directory that sounds just like your stuff directory to another hard disk every night, and just like with Penguin that has saved me -big time- at least a couple times. selected really important stuff i back up to CD also. if the directory is really big, you can use something like bzip to really compress it. believe me, backing up is definitely worth it.
Offline
I agree with the backup, i would be more worried about a harddrive or filesystem failure than accidentally typing rm -r ~/stuff. that seems like a difficult mistake.
Offline
I agree with the backup, i would be more worried about a harddrive or filesystem failure than accidentally typing rm -r ~/stuff. that seems like a difficult mistake.
Err.. see almost every post in this thread.
Offline
Offline
How long would it take to:
- bzip
- gzip
250GB on a SATAII then copy to a USB2.0 hard drive (AMD 3200+)?
Basically, would I be able to back up 250GB within 8 hours?
Also, if I'm archiving my home directory overnight, whilst I'm downloading files how would this be dealt with? I guess it has something to do with my filesystem: ext3.
Offline
I would advise against replacing a real command with an alias. The reason being if for some reason (and there are many) the alias doesn't exists when you think it does, so you think your're safe doing rm -rf stuff but in actual fact you've just deleted all your important files.
One thing you can do is implement a rudimentary 'recycle bin'. Choose a name that isn't a real command on your system. 'del' might be a good one and alias that to `mv "$@" ~/.Trash`.
IMHO, by far the best thing to do is implement a backup system. The particular method I implement doesn't require much more space than the files your backing up unless your continously changing, deleting creating hundreds of files. A howto that I based my backup implementation on can be found here: http://www.mikerubel.org/computers/rsync_snapshots/
Edit (to answer some of your questions):
When your downloading stuff (of the internet I presume) then the speed of your internet connection is typically much slower than that of disk IO, so it shouldn't effect it much. Typically when the backup script reaches the file that your downloading it will just backup the partially downloaded file, or thats whats happened in my experience.
bzip will take much longer than gzip, though I can't really say how long it would take to back up 250 gigs worth, 8 hours sounds a reasonable estimation, to me anyhow.
Offline
You only have to backup the whole stuff of 250 GB once. After that, you may use rsync to only write the diffs to your backup dir!
May take some time with 250 gigs and depends on the type of files you have there, if it is like the pacman-db (maaaany small files) it may take longer but probably not 8 hours
Offline
I've made many large drive images with ghost on internal (ide/sata) and external USB2 disks.
With IDE ATA133 or SATA drives i achieve get 50-60 GiB per hour minute, USB2 however only manages 20-30 Gib per hour.
A lot will depend on how well your data compresses.
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
(A works at time B) && (time C > time B ) ≠ (A works at time C)
Offline
Why backup your entire home directory? Surely not everything there is important. Only backup what you cannot replace or what is a huge pain in the ass to replace. DVD-RWs are great for backing up important data, but may become too much trouble with massive directories (250GB! holy shit).
Why not just use RAID? If the data is truely important and cannot be replaced then you should utilize some form of redundant disk array. Internal hard drives and IDE/SATA raid controllers are very cheap now, so this is more of an option to everyone than a few years back.
Offline
Pages: 1