DbAppWeb.com

Menu
  • Home
  • Linux
  • HP-UX
  • macOS
  • Windows
  • Web Servers
  • App Servers
  • Storage

How to create tar archive and remove original files

February 22, 2018 DbAppWeb Admin

Sometimes we need to remove or delete the files after creating the tar archive to increase the free space. Use the tar command with –remove-files option to remove/delete the files after creating the tar archive.

List the files

[root@dbappweb logs_backup]# ll
total 1015088
-rw-r--r-- 1 root root 810695 Dec 31 04:00 access_log.4
-rw-r--r-- 1 root root 311080 Dec 31 04:00 deflate_log.4
-rw-r--r-- 1 root root 3742 Dec 31 04:02 error_log.4
-rw-r--r-- 1 root root 89191119 Dec 31 04:02 ssl_access_log.4
-rw-r--r-- 1 root root 845278 Dec 31 04:00 ssl_error_log.4
-rw-r--r-- 1 root root 89191119 Dec 31 04:02 ssl_access_log.4

Create a tar archive using the tar command

[root@dbappweb logs_backup]# tar -cvzf dbappweb_31Dec2017.tar.gz *.4 --remove-files
access_log.4
deflate_log.4
error_log.4
ssl_access_log.4
ssl_error_log.4
ssl_request_log.4

tar created and original files removed

[root@dbappweb logs_backup]# ll
total 221676
-rw-r--r-- 1 root root 9184120 Feb 15 10:14 dbappweb_31Dec2017.tar.gz

You can see all files under newly created tar by using the command tar -tvzf

[root@dbappweb logs_backup]# tar -tvzf dbappweb_31Dec2017.tar.gz
-rw-r--r-- root/root 810695 2017-12-31 04:00:07 access_log.4
-rw-r--r-- root/root 311080 2017-12-31 04:00:07 deflate_log.4
-rw-r--r-- root/root 3742 2017-12-31 04:02:21 error_log.4
-rw-r--r-- root/root 89191119 2017-12-31 04:02:19 ssl_access_log.4
-rw-r--r-- root/root 845278 2017-12-31 04:00:10 ssl_error_log.4
-rw-r--r-- root/root 99193865 2017-12-31 04:02:19 ssl_request_log.4

To extract the files from tar use the command tar -xvzf

[root@dbappweb logs_backup]# tar -xvzf dbappweb_31Dec2017.tar.gz

 

 

Prev Article
Next Article
Tags:File System Linux Mac OS X Sys Admin tar tar.gz

Leave a Reply Cancel Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Popular
  • Recent

Categories

  • Android (2)
  • Blogger (16)
  • Domain and Hosting (1)
  • Hardware Issues (7)
  • HP-UX (55)
  • HPE Data Protector (9)
  • IBM Lotus Notes (2)
  • IBM WebSphere Application Server (16)
  • Internet Tips & Tricks (15)
  • iOS (8)
  • JBoss/WildFly Application Server (2)
  • Linux (76)
  • macOS (15)
  • Microsoft Windows (31)
  • News and Updates (11)
  • Oracle Database (5)
  • SSL/TLS (1)
  • Storage Servers (23)
  • Tools/Softwares (1)
  • VMware ESXi (17)
  • Web Servers (14)
  • WordPress (5)

Archives

DbAppWeb.com

Solution of Database, Application and Web Server Problems

About DbAppWeb.com

One Stop Solution for Database Server, Application Server and Web Server Problems.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

DbAppWeb on Social Media

Copyright © 2025 DbAppWeb.com
Terms and Conditions   Theme by MyThemeShop.com