Warm tip: This article is reproduced from serverfault.com, please click

How do I tar a directory without retaining the directory structure?

发布于 2011-04-17 19:29:02

I'm working on a backup script and want to tar up a file directory:

tar czf ~/backup.tgz /home/username/drupal/sites/default/files

This tars it up, but when I untar the resulting file, it includes the full file structure: the files are in home/username/drupal/sites/default/files.

Is there a way to exclude the parent directories, so that the resulting tar just knows about the last directory (files)?

Questioner
Brock Boland
Viewed
0
John Gibb 2011-04-18 03:33:23
cd /home/username/drupal/sites/default/files
tar czf ~/backup.tgz *