LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-13-2015, 07:22 AM   #1
raguetrenaud
LQ Newbie
 
Registered: Jul 2015
Posts: 3

Rep: Reputation: Disabled
tar + split + output


Hello,

I have this command:

$TAR -cvf - $SOURCEDIR $EXCLUDEDIR | split --bytes=1999m - $BACKUP_DEVICE 1>/usr/backup/backuped_files.lst

this part is working as expected:

$TAR -cvf - $SOURCEDIR $EXCLUDEDIR | split --bytes=1999m - $BACKUP_DEVICE

this part is not working:

1>/usr/backup/backuped_files.lst

My purpose is to catch the backuped files in backuped_files.lst (screen output without errors)
Can you help me?

Regards,

Renaud

Last edited by raguetrenaud; 07-13-2015 at 08:32 AM.
 
Old 07-13-2015, 07:30 AM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Because of the pipe, the redirect is only catching output of the second command. Put the redirect before the pipe like this:

Code:
$TAR -cvf - $SOURCEDIR $EXCLUDEDIR 1>/usr/backup/backuped_files.lst | split --bytes=1999m - $BACKUP_DEVICE
You can use 'tee' for strange redirections if you want to read up on it.
 
Old 07-13-2015, 08:10 AM   #3
raguetrenaud
LQ Newbie
 
Registered: Jul 2015
Posts: 3

Original Poster
Rep: Reputation: Disabled
thx

i tested it:

redhat #tar cvf - /usr/backup/ --exclude=/usr/backup/logs 1>/usr/backuped_files.lst | split --bytes=1m - /usr/tartestoutput.tar.
tar: Removing leading `/' from member names
usr/backup/
usr/backup/backup.log
usr/backup/testje.sh
usr/backup/backuped_files.lst
usr/backup/1
usr/backup/backup2.sh
usr/backup/backup3.sh
usr/backup/çwq!
usr/backup/mount_backup.sh
usr/backup/umount_backup.sh
usr/backup/cpio_to_export_backup.sh
usr/backup/backup_functions.sh
usr/backup/daily_backup.sh
usr/backup/transferred_files_beukdb3.lst
usr/backup/online_backup_varlab.sh
usr/backup/transferred_files_beukdb4.lst
usr/backup/cpio_to_export_backupcold.sh
usr/backup/weekly_cold_backup.sh
usr/backup/rman_varlab.sh
usr/backup/mount_backup.sh.28112007
usr/backup/daily_backup_copy.sh
usr/backup/weeklytest.sh
usr/backup/backup_functions.sh.28112007
usr/backup/backup_functions.sh.090708
usr/backup/mount_backup_ict.sh
usr/backup/umount_backup_ict.sh
usr/backup/today1.log
redhat#

the backuped_files.lst file is 100M and contains logs from 10 july 2015
no tar created

tar cvf - /usr/backup/ --exclude=/usr/backup/logs | split --bytes=1m - /usr/tartestoutput.tar. (worked as expected)
 
Old 07-14-2015, 04:10 AM   #4
raguetrenaud
LQ Newbie
 
Registered: Jul 2015
Posts: 3

Original Poster
Rep: Reputation: Disabled
solution

hello,

i found a workaround (not clean but working…):

i inserted tags (tar start and tar end)in my log file and i used /bin/sed to extract tar logs from it.

extract tar logs from backup.log to backuped_files.lst
Code:
sed -n '/^tar start/,/^tar end/p' backup.log > backuped_files.lst
remove tar logs from backup.log
Code:
sed '/^tar start/,/^tar end/d' backup.log > backup.log

Regards,

Renaud
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Using split and tar to get the compressed files ytyyutianyun Linux - Newbie 10 12-12-2013 07:08 PM
tar + split question 300zxkyle Linux - Software 9 01-14-2012 06:19 AM
Tar split into small files jmoschetti45 Linux - Software 1 02-07-2011 05:44 PM
tar, split, burn to dvd result to tar file corruption fedusr Fedora 8 11-30-2007 04:39 PM
split or tar -M -L? Slacker0815 Linux - Software 3 06-05-2006 04:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration