How to backup a directory using tar in one line.

April 5, 2008 at 2:09 pm 1 comment

This is all terribly simple… but I’m rather inclined to forget it. The reason I’m putting this here is that I’ve written something like this at least twice.

file=$(basename `pwd`);
backupName=$file-$(date +%Y-%m-%d.tgz);
tar -C .. -czf $backupName $file --exclude=$file/$backupName

This creates a gunzipped tar file of the current directory, in the current directory and includes the current date in the name. This is quite useful for your home directory.

Advertisements

Entry filed under: Uncategorized. Tags: , , .

A local firewall for ubuntu How configuration should work.

1 Comment Add your own

  • 1. Sara Trice  |  August 4, 2010 at 3:54 pm

    Thanks! This was very helpful when I had to manually upgrade wordpress today. 🙂

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


April 2008
M T W T F S S
« Mar   May »
 123456
78910111213
14151617181920
21222324252627
282930  

%d bloggers like this: