Open main menu

Changes

1,416 bytes added ,  23:30, 28 March 2015
Adds use case
GNU Tar is everybody's favorite archive file format.
 
== Use Cases ==
=== Get just one file ===
<code>drush archive-backup (arb)</code> and <code>drush archive-restore (arr)</code> are great commands for making a full site backup prior to changes; that you can use to restore from. Your entire Drupal instance (code, settings, modules, plus database) are all tar'd into an archive file, and gzip compressed <ref>The example refers to a .tar file. <code>drush archive-backup</code> creates a .tar.gz file -- meaning it's compressed with gzip. So, to work with the .tar file, first you would uncompress the .tar.gz file with <code>gunzip file.tar.gz</code></ref>. Again, one of the things that <code>drush arb</code> does is create a SQL dump file. What if you want just that dump file from the archive? The long way would be to extract the whole thing, find and move the bits you want, and then discard the rest. Or, you could just tell tar to give you the file you want explicitly:
<source lang="bash">
# look at what's in the archive
tar -tf ~/drush-backups/archive-dump/20150327030955/freephile_drupal.20150327_030955.tar
# request just the SQL dump file (puts it into the current working directory)
tar -xf ~/drush-backups/archive-dump/20150327030955/freephile_drupal.20150327_030955.tar freephile_drupal.sql
</source>
 
=== Strip top level of the archive and don't extract a sub-folder ===
The magic tar one-line command to unpack a Drupal distribution over an
existing Drupal directory (without clobbering your "sites" directory)
done
</source>
 
{{References}}
4,558

edits