Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copying files into a gzip 1

Status
Not open for further replies.

Hondy

Technical User
Mar 3, 2003
864
GB
Hi

I'm sure this is easy but I'm a noob at this Linux command stuff.

What I would like to do is basically:

Copy \var\myfiles\*.* to \var\myfiles\backup\myfiles.gzip, including all subdirectories.

I will then use this on a cron job shell script on a daily basis which I have worked out already. I'm using Centos btw.

Thanks



 
The normal method is to use tar:
[tt]
tar -czf /var/myfiles/backup/myfiles.tar.gz /var/myfiles/
[/tt]
That will copy the entire directory into a tar archive file, then compress it using gzip. .tar.gz is the standard extension for a gzipped tar file.
 
Hold on a sec. You're creating the backup file inside the directory you're backing up? I don't think that can be done, or if it can it's dodgy practice. You'd need to create it somewhere else.

While you're at it, you might like to consider moving /var/myfiles to something like /var/local/myfiles. The Linux Filesystem Hierarchy Standard (FHS) only allows a small defined set of /var subdirectories.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top