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
)?
Use the --directory option:
tar czf ~/backup.tgz --directory=/home/username/drupal/sites/default files