Hello All,
I seem to be having an issue with file extraction on centOS 7.
Scenario:
PC1 is collecting .csv and .txt extension files into one directory, every 5 minutes everything inside this directory is tarballed and compressed into a .tar.gz file using a cron job. So the file looks something like the below:
pc1_'date_timestamp'.tar.gz
These .tar.gz files are then moved to a remote server.
Question:
On the remote server, how do you extract these .tar.gz files to retrieve the .txt and .csv files into one singular file and how do you delete / remove these extracted file to reclaim space?
Note: All the .csv and .txt files have unique namining conventions prior to be being tarballed so duplication won't be an issue.
Errors I am seeing:
tar: Exiting with failure status due to previous errors
Any advice or assistance will be deeply appreciated.
Linux file compression and extraction (CentOS)
Re: Linux file compression and extraction (CentOS)
Same way you would untar the on the original machine: tar -tf /path/to/pc1_'date_timestamp'.tar.gz
If that tar command above works then the tar archive is OK and you can re-run the command and change -tf to -xf (test files to extract files). If it doesn't work then it's possible that the tar archive is corrupt.
Show exact errors if you need more help.
If that tar command above works then the tar archive is OK and you can re-run the command and change -tf to -xf (test files to extract files). If it doesn't work then it's possible that the tar archive is corrupt.
Show exact errors if you need more help.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Re: Linux file compression and extraction (CentOS)
Hello Trevor,
Thank you for your response. I've added some more information, which should help explain what I'm attempting to do.
tree output
.
├── created_files
│ ├── test_02-08-2022_11-58-01.csv
│ ├── test_02-08-2022_11-58-01.json
│ └── test_02-08-2022_11-58-01.txt
├── extracted_files
└── zipped_files
├── backup_02-08-2022_11-48-01.tar.gz
├── backup_02-08-2022_11-51-01.tar.gz
└── backup_02-08-2022_11-57-01.tar.gz
tar
[admin@alfred]$ tar -tf /home/admin/zipped_files/backup_*
tar: /home/admin/zipped_files/backup_02-08-2022_11-51-01.tar.gz: Not found in archive
tar: /home/admin/zipped_files/backup_02-08-2022_11-57-01.tar.gz: Not found in archive
tar: Exiting with failure status due to previous errors
[admin@alfred]$ tar -zxf /home/admin/zipped_files/backup_*
tar: /home/admin/zipped_files/backup_02-08-2022_11-51-01.tar.gz: Not found in archive
tar: /home/admin/zipped_files/backup_02-08-2022_11-57-01.tar.gz: Not found in archive
tar: /home/admin/zipped_files/backup_02-08-2022_12-00-01.tar.gz: Not found in archive
tar: Exiting with failure status due to previous errors
ll
[admin@alfred]$ ll /home/admin/zipped_files/
total 24
-rw-r--r--. 1 admin admin 180 Aug 2 11:48 backup_02-08-2022_11-48-01.tar.gz
-rw-r--r--. 1 admin admin 181 Aug 2 11:51 backup_02-08-2022_11-51-01.tar.gz
-rw-r--r--. 1 admin admin 213 Aug 2 11:57 backup_02-08-2022_11-57-01.tar.gz
-rw-r--r--. 1 admin admin 249 Aug 2 12:00 backup_02-08-2022_12-00-01.tar.gz
-rw-r--r--. 1 admin admin 259 Aug 2 12:03 backup_02-08-2022_12-03-01.tar.gz
-rw-r--r--. 1 admin admin 267 Aug 2 12:06 backup_02-08-2022_12-06-01.tar.gz
[admin@alfred]$ tar -ztvf /home/admin/zipped_files/*.tar.gz
tar: /home/admin/zipped_files/backup_02-08-2022_11-51-01.tar.gz: Not found in archive
tar: /home/admin/zipped_files/backup_02-08-2022_11-57-01.tar.gz: Not found in archive
tar: /home/admin/zipped_files/backup_02-08-2022_12-00-01.tar.gz: Not found in archive
tar: /home/admin/zipped_files/backup_02-08-2022_12-03-01.tar.gz: Not found in archive
tar: /home/admin/zipped_files/backup_02-08-2022_12-06-01.tar.gz: Not found in archive
tar: Exiting with failure status due to previous errors
[admin@alfred]$ tar -ztvf /home/admin/zipped_files/backup_02-08-2022_11-48-01.tar.gz
-rw-r--r-- admin/admin 0 2022-08-02 11:46 home/admin/created_files/test_02-08-2022_11-46-01.txt
-rw-r--r-- admin/admin 0 2022-08-02 11:47 home/admin/created_files/test_02-08-2022_11-47-01.txt
-rw-r--r-- admin/admin 0 2022-08-02 11:48 home/admin/created_files/test_02-08-2022_11-48-01.txt
[admin@alfred]$ tar -ztvf /home/admin/zipped_files/backup_02-08-2022_12-06-01.tar.gz
-rw-r--r-- admin/admin 0 2022-08-02 12:03 home/admin/created_files/test_02-08-2022_12-03-01.csv
-rw-r--r-- admin/admin 0 2022-08-02 12:04 home/admin/created_files/test_02-08-2022_12-04-01.csv
-rw-r--r-- admin/admin 0 2022-08-02 12:04 home/admin/created_files/test_02-08-2022_12-04-01.json
-rw-r--r-- admin/admin 0 2022-08-02 12:04 home/admin/created_files/test_02-08-2022_12-04-01.txt
-rw-r--r-- admin/admin 0 2022-08-02 12:05 home/admin/created_files/test_02-08-2022_12-05-01.csv
-rw-r--r-- admin/admin 0 2022-08-02 12:05 home/admin/created_files/test_02-08-2022_12-05-01.json
-rw-r--r-- admin/admin 0 2022-08-02 12:05 home/admin/created_files/test_02-08-2022_12-05-01.txt
-rw-r--r-- admin/admin 0 2022-08-02 12:06 home/admin/created_files/test_02-08-2022_12-06-01.csv
-rw-r--r-- admin/admin 0 2022-08-02 12:06 home/admin/created_files/test_02-08-2022_12-06-01.json
-rw-r--r-- admin/admin 0 2022-08-02 12:06 home/admin/created_files/test_02-08-2022_12-06-01.txt
Thank you for your response. I've added some more information, which should help explain what I'm attempting to do.
tree output
.
├── created_files
│ ├── test_02-08-2022_11-58-01.csv
│ ├── test_02-08-2022_11-58-01.json
│ └── test_02-08-2022_11-58-01.txt
├── extracted_files
└── zipped_files
├── backup_02-08-2022_11-48-01.tar.gz
├── backup_02-08-2022_11-51-01.tar.gz
└── backup_02-08-2022_11-57-01.tar.gz
tar
[admin@alfred]$ tar -tf /home/admin/zipped_files/backup_*
tar: /home/admin/zipped_files/backup_02-08-2022_11-51-01.tar.gz: Not found in archive
tar: /home/admin/zipped_files/backup_02-08-2022_11-57-01.tar.gz: Not found in archive
tar: Exiting with failure status due to previous errors
[admin@alfred]$ tar -zxf /home/admin/zipped_files/backup_*
tar: /home/admin/zipped_files/backup_02-08-2022_11-51-01.tar.gz: Not found in archive
tar: /home/admin/zipped_files/backup_02-08-2022_11-57-01.tar.gz: Not found in archive
tar: /home/admin/zipped_files/backup_02-08-2022_12-00-01.tar.gz: Not found in archive
tar: Exiting with failure status due to previous errors
ll
[admin@alfred]$ ll /home/admin/zipped_files/
total 24
-rw-r--r--. 1 admin admin 180 Aug 2 11:48 backup_02-08-2022_11-48-01.tar.gz
-rw-r--r--. 1 admin admin 181 Aug 2 11:51 backup_02-08-2022_11-51-01.tar.gz
-rw-r--r--. 1 admin admin 213 Aug 2 11:57 backup_02-08-2022_11-57-01.tar.gz
-rw-r--r--. 1 admin admin 249 Aug 2 12:00 backup_02-08-2022_12-00-01.tar.gz
-rw-r--r--. 1 admin admin 259 Aug 2 12:03 backup_02-08-2022_12-03-01.tar.gz
-rw-r--r--. 1 admin admin 267 Aug 2 12:06 backup_02-08-2022_12-06-01.tar.gz
[admin@alfred]$ tar -ztvf /home/admin/zipped_files/*.tar.gz
tar: /home/admin/zipped_files/backup_02-08-2022_11-51-01.tar.gz: Not found in archive
tar: /home/admin/zipped_files/backup_02-08-2022_11-57-01.tar.gz: Not found in archive
tar: /home/admin/zipped_files/backup_02-08-2022_12-00-01.tar.gz: Not found in archive
tar: /home/admin/zipped_files/backup_02-08-2022_12-03-01.tar.gz: Not found in archive
tar: /home/admin/zipped_files/backup_02-08-2022_12-06-01.tar.gz: Not found in archive
tar: Exiting with failure status due to previous errors
[admin@alfred]$ tar -ztvf /home/admin/zipped_files/backup_02-08-2022_11-48-01.tar.gz
-rw-r--r-- admin/admin 0 2022-08-02 11:46 home/admin/created_files/test_02-08-2022_11-46-01.txt
-rw-r--r-- admin/admin 0 2022-08-02 11:47 home/admin/created_files/test_02-08-2022_11-47-01.txt
-rw-r--r-- admin/admin 0 2022-08-02 11:48 home/admin/created_files/test_02-08-2022_11-48-01.txt
[admin@alfred]$ tar -ztvf /home/admin/zipped_files/backup_02-08-2022_12-06-01.tar.gz
-rw-r--r-- admin/admin 0 2022-08-02 12:03 home/admin/created_files/test_02-08-2022_12-03-01.csv
-rw-r--r-- admin/admin 0 2022-08-02 12:04 home/admin/created_files/test_02-08-2022_12-04-01.csv
-rw-r--r-- admin/admin 0 2022-08-02 12:04 home/admin/created_files/test_02-08-2022_12-04-01.json
-rw-r--r-- admin/admin 0 2022-08-02 12:04 home/admin/created_files/test_02-08-2022_12-04-01.txt
-rw-r--r-- admin/admin 0 2022-08-02 12:05 home/admin/created_files/test_02-08-2022_12-05-01.csv
-rw-r--r-- admin/admin 0 2022-08-02 12:05 home/admin/created_files/test_02-08-2022_12-05-01.json
-rw-r--r-- admin/admin 0 2022-08-02 12:05 home/admin/created_files/test_02-08-2022_12-05-01.txt
-rw-r--r-- admin/admin 0 2022-08-02 12:06 home/admin/created_files/test_02-08-2022_12-06-01.csv
-rw-r--r-- admin/admin 0 2022-08-02 12:06 home/admin/created_files/test_02-08-2022_12-06-01.json
-rw-r--r-- admin/admin 0 2022-08-02 12:06 home/admin/created_files/test_02-08-2022_12-06-01.txt
Re: Linux file compression and extraction (CentOS)
Essentially, I'm attempting to extract all of the files contained within the tar.gz files in the zipped directory, or to extract/move them to the extracted file if possible.
At the moment I am just struggling to retrieve the contents inside the .tar.gz files.
At the moment I am just struggling to retrieve the contents inside the .tar.gz files.
Re: Linux file compression and extraction (CentOS)
So this
When you run that, tar interprets the file filename it is given as the archive to extract and then searches through that archive looking for any of the other named files you appended to the command. Unsurprisingly it doesn't find those inside the 1st rchive so it ends with an error.
What you really want to do is something like
for file in /home/admin/zipped_files/backup_*.tar.gz; do tar -tf $file;done
Though actually you probably don't really want to do that as it would test each and every archive in that directory (or extract them if you use -xf)
is expanded by bash into tar -tf /home/admin/zipped_files/backup_02-08-2022_11-48-01.tar.gz /home/admin/zipped_files/backup_02-08-2022_11-51-01.tar.gz /home/admin/zipped_files/backup_02-08-2022_11-57-01.tar.gz /home/admin/zipped_files/backup_02-08-2022_12-00-01.tar.gz /home/admin/zipped_files/backup_02-08-2022_12-03-01.tar.gz /home/admin/zipped_files/backup_02-08-2022_12-06-01.tar.gz[admin@alfred]$ tar -tf /home/admin/zipped_files/backup_*
tar: /home/admin/zipped_files/backup_02-08-2022_11-51-01.tar.gz: Not found in archive
tar: /home/admin/zipped_files/backup_02-08-2022_11-57-01.tar.gz: Not found in archive
tar: Exiting with failure status due to previous errors
When you run that, tar interprets the file filename it is given as the archive to extract and then searches through that archive looking for any of the other named files you appended to the command. Unsurprisingly it doesn't find those inside the 1st rchive so it ends with an error.
What you really want to do is something like
for file in /home/admin/zipped_files/backup_*.tar.gz; do tar -tf $file;done
Though actually you probably don't really want to do that as it would test each and every archive in that directory (or extract them if you use -xf)
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Re: Linux file compression and extraction (CentOS)
Hi Trevor,
Your suggestion of using for using "for file in /home/admin/zipped_files/backup_*.tar.gz; do tar -tf $file;done" worked. Thank you!
Your suggestion of using for using "for file in /home/admin/zipped_files/backup_*.tar.gz; do tar -tf $file;done" worked. Thank you!