LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   tar + split + output (https://www.linuxquestions.org/questions/linux-newbie-8/tar-split-output-4175547863/)

raguetrenaud 07-13-2015 07:22 AM

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

szboardstretcher 07-13-2015 07:30 AM

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.

raguetrenaud 07-13-2015 08:10 AM

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)

raguetrenaud 07-14-2015 04:10 AM

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


All times are GMT -5. The time now is 12:35 AM.