Linux.com

Home Linux Community Community Blogs General Linux 2 cent Linux tip - using find and tar for a selective backup.

2 cent Linux tip - using find and tar for a selective backup.

So I'm blowing away, and re-installing, my Steam Bottle on Codeweaver's Crossover games. I was hoping to get some in-game overlay support for the Community/Friends features of Steam. I really really want to hang on to Team Fortress/Left 4 Dead settings though.

Using the find command we can solve this problem fairly easy.

 

 

So the basic requirements in this scenario boil down to finding all the config files under the ~/.cxgames tree. I have a ~/etc directory to keep a backup of important things such as settings and handy scripts. I will copy my tar file to the ~/etc directory so I can find it easily later. However, I don't want every *.cfg file under my Steam bottle, just the ones for those specific games (Team Fortress and Left 4 Dead). When I run the following command, I'll discover those games have a common top-level directory, "~.cxgames/Steam/drive_c/Program Files/Steam/steamapps".

find ~/.cxgames -name "*.cfg"

When I run the following command, however, I'll get an error due to spaces in the directory/filename structure.  Note the backslash in "Program Files" is an escaped space for the shell to properly interpret this.

find .cxgames/Steam/drive_c/Program Files/Steam/steamapps/ | xargs tar -rf ~/etc/steam-settings.tar

The find command has a switch -print0 to deal with this, and xargs will process this find output format with the -0 flag. Therefore the following command will get the files I need

find ~/.cxgames/Steam/drive_c/Program Files/Steam/steamapps/ -name "*.cfg" -print0 | xargs -0 tar -rf ~/etc/steam-settings.tar

Restoring is as simple as running, the following command from within my home directory.

tar xvf ~/etc/steam-settings.tar

Perhaps some day we'll have a Linux steam client, and a promotional TF2 item named the Unix Pipe.

 

Comments

Subscribe to Comments Feed

Upcoming Linux Foundation Courses

  1. LFD320 Linux Kernel Internals and Debugging
    03 Nov » 07 Nov - Virtual
    Details
  2. LFS416 Linux Security
    03 Nov » 06 Nov - Virtual
    Details
  3. LFS426 Linux Performance Tuning
    10 Nov » 13 Nov - Virtual
    Details

View All Upcoming Courses


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board