LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Best way to back up directories? (https://www.linuxquestions.org/questions/linux-newbie-8/best-way-to-back-up-directories-211123/)

sdebiasio 07-29-2004 01:37 PM

Best way to back up directories?
 
Hi - I am wondering what is the best way to do a manual backup of our disk's directories. I tried using the "cp r- " command to copy the live disk (1) to our backup disk (2), but what that seems to do instead is create a brand new backup copy of the directory within the same folder, I have no idea why. All I want to do is overwrite the existing backup with a new backup.

What am I missing here?

Thanks in advance ...

:confused:

btmiller 07-29-2004 01:40 PM

Hi, and welcome to LQ!

You want:

cp -a /your/directory /backup/location

-a stands for archive and implies a recursive copy that preserves file permissions and attributes as much as possible.

sdebiasio 07-29-2004 01:52 PM

Perfect! Thank you so much, that did it.

My next question is -- how do I get rid of the prompting? Because when I'm doing a backup of say, 100 directories, I can't sit there and say "y" to every one of them.

Any ideas?

Thanks again.

linuxlastslonge 07-29-2004 02:00 PM

simply tar everything to a gzipped-tarball and put it on that drive:

Code:

tar -czvf /backup/drive/backup.tgz /directories /to /backup

then, if you wish, extract them to the new hdd:

Code:

tar -xzvf backup.tgz
BE SURE YOU ARE IN THE DIRECTORY YOU INTEND TO EXTRACT THE ARCHIVE TO WHEN YOU RUN THE ABOVE COMMAND.


hope this helps!

sdebiasio 07-30-2004 08:46 AM

Thank you! That worked wonderfully! I appreciate the help.

theYinYeti 07-30-2004 09:04 AM

The surest way I know of copying directories is as follows:
Let's assume you have /usr/local/share, all of which you want to backup under /backup/share. You would do
# (cd /usr/local && tar cf - share) | (cd /backup && tar xpf -)

Yves.


All times are GMT -5. The time now is 08:34 PM.