Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: How do I automate or make an alias of this task?

  1. #11
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,467
    Distro
    Ubuntu Mate

    Lightbulb Re: How do I automate or make an alias of this task?

    Eureka!

    Code:
    tar czvf ~/Documents/Software/SportsTracker_4.1.1/SportsTrackerBackup.tar.gz ~/.sportstracker
    All thats left is to put this into an alias.
    Code:
    alias stb='tar czvf ~/"Documents/Software/SportsTracker_4.1.1/SportsTrackerBackup.tar.gz" ~/.sportstracker'
    Last edited by Rytron; March 30th, 2010 at 07:42 PM.
    1st Distro used (live CD): Knoppix in early 2007 ¦ 1st Distro Installed: Ubuntu 7.10 in Feb 2008
    GNU/Linux User #470660 – Ubuntu User #28226
    Isaac Asimov: "I do not fear computers. I fear the lack of them."

  2. #12
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,467
    Distro
    Ubuntu Mate

    Question Re: How do I automate or make an alias of this task?

    The only downside is that it backs the .sportstracker file in an archive with this structure:
    /home/rytron/.sportstracker/
    Do I need to change something in the tar czvf part (or use another form of compression?). It's no big deal but if I could only backup the .sportstracker without the full path structure, it'd be better.
    1st Distro used (live CD): Knoppix in early 2007 ¦ 1st Distro Installed: Ubuntu 7.10 in Feb 2008
    GNU/Linux User #470660 – Ubuntu User #28226
    Isaac Asimov: "I do not fear computers. I fear the lack of them."

  3. #13
    Join Date
    Jun 2008
    Location
    California
    Beans
    2,271
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: How do I automate or make an alias of this task?

    Quote Originally Posted by Rytron View Post
    ..Do I need to change something in the tar czvf part (or use another form of compression?). It's no big deal but if I could only backup the .sportstracker without the full path structure, it'd be better.
    I use zip rather than tar, but zip saves relative directores. For example, if the working directory is my home directory, the following command saves the documents directory and all files in the documents directory but not the full path.

    Code:
    zip test.zip documents/*
    If I unzip test.zip, it creates the documents directory in the current working directory.

    Zip also has an option that ignores all directories, but if I understand correctly you want to retain the one directory.

  4. #14
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,467
    Distro
    Ubuntu Mate

    Question Re: How do I automate or make an alias of this task?

    Quote Originally Posted by kaibob View Post
    I use zip rather than tar, but zip saves relative directores. For example, if the working directory is my home directory, the following command saves the documents directory and all files in the documents directory but not the full path.

    Code:
    zip test.zip documents/*
    If I unzip test.zip, it creates the documents directory in the current working directory.

    Zip also has an option that ignores all directories, but if I understand correctly you want to retain the one directory.
    How do I get zip to ignore all directories? What option do I use?

    This kept the full path structure also just like tar did. The only difference was the better compression ratio that zip offered.
    Code:
    alias stb='zip ~/"Documents/Software/SportsTracker_4.1.1/SportsTrackerBackup.zip" ~/.sportstracker'
    1st Distro used (live CD): Knoppix in early 2007 ¦ 1st Distro Installed: Ubuntu 7.10 in Feb 2008
    GNU/Linux User #470660 – Ubuntu User #28226
    Isaac Asimov: "I do not fear computers. I fear the lack of them."

  5. #15
    Join Date
    Dec 2007
    Location
    Gainesville, Florida
    Beans
    Hidden!
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: How do I automate or make an alias of this task?

    try bzip2

    Code:
    tar cjvf ~/Documents/Software/SportsTracker_4.1.1 SportsTrackerBackup.tar.bz2 ~/.sportstracker
    Also the way to get only the files in ~./sportstracker is to cd to that directory and archive from there.

    Code:
    cd ~/.sportstracker && tar cjvf ~/Documents/Software/SportsTracker_4.1.1/SportsTrackerBackup.tar.bz2 *

  6. #16
    Join Date
    Jun 2008
    Location
    California
    Beans
    2,271
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: How do I automate or make an alias of this task?

    Quote Originally Posted by Rytron View Post
    How do I get zip to ignore all directories? What option do I use?

    This kept the full path structure also just like tar did. The only difference was the better compression ratio that zip offered.
    Code:
    alias stb='zip ~/"Documents/Software/SportsTracker_4.1.1/SportsTrackerBackup.zip" ~/.sportstracker'
    You use the -j option, which is described in the man page as:

    Store just the name of a saved file (junk the path), and do not store directory names. By default, zip will store the full path (relative to the current path).
    Thus, for example

    Code:
    zip -j test.zip /home/kaibob/documents/*
    As to your second question, execute the following in a terminal window while the current working directory is the parent directory of .sportstracker. This is a bit cumbersome with an alias and might best be handled as a function or separate shell script.

    Code:
    zip ~/"Documents/Software/SportsTracker_4.1.1/SportsTrackerBackup.zip" .sportstracker/*
    Last edited by kaibob; March 31st, 2010 at 11:22 PM.

  7. #17
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,467
    Distro
    Ubuntu Mate

    Wink Re: How do I automate or make an alias of this task?

    Thank you all for your assistance. Cheers.
    1st Distro used (live CD): Knoppix in early 2007 ¦ 1st Distro Installed: Ubuntu 7.10 in Feb 2008
    GNU/Linux User #470660 – Ubuntu User #28226
    Isaac Asimov: "I do not fear computers. I fear the lack of them."

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •