LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 12-23-2011, 12:47 AM   #1
Vi_rod
Member
 
Registered: Dec 2011
Posts: 42

Rep: Reputation: Disabled
Using TAR to create backup of files created today in data directory


Using TAR command is it possible to take backup of files created today??

played around with ->

cd /opt/backup/
find . -mtime -1 -type f -print > $INPUT_FILE
for i in $(cat $INPUT_FILE); do
echo "line: $i";
tar --append --file=$OUTPUT_FILE $i
done


it gives me a strange and different error everytime.. any suggestions on improving the script?
 
Old 12-23-2011, 01:17 AM   #2
coolsg5636
Member
 
Registered: Sep 2011
Location: Pune,India
Distribution: RHEL ,CentOS, Fedora
Posts: 100

Rep: Reputation: 25
Hello,

This script doesn't seem to be complete. Please paste the complete script and also paste the error message.
 
Old 12-23-2011, 04:04 AM   #3
sathish_s
LQ Newbie
 
Registered: Aug 2011
Posts: 9

Rep: Reputation: Disabled
i think below will help u

find . -mtime -1 -type f |xargs tar cvzf test.tar



thanks

sathish
 
Old 12-23-2011, 01:00 PM   #4
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Dehradun, Uttarakhand, India
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,413

Rep: Reputation: 303Reputation: 303Reputation: 303Reputation: 303
Yes, using tar command it is possible to take backup of files created today. I will give you an example of my shell script which I use for creating backup every sunday.
This is the example of my case on my server which I use it:

I had automated a little shell script that basically mounts my backup drive, checks the date, every sunday it makes a full backup of some datafiles and some configuration settings, older incremental backups are removed. other days it backups files that have been accessed the last day and at last it unmounts the backup drive.

And here is the code which I use:

Code:
#!/bin/bash

DATA="/home /root /usr/local/httpd"
CONFIG="/etc /var/lib /var/named"
LIST="/tmp/backlist_$$.txt"

mount /mnt/backup
set $(date)

if test "$1" = "Sun" ; then
        # weekly a full backup of all data and config. settings:
        #
        tar cfz "/mnt/backup/data/data_full_$6-$2-$3.tgz" $DATA
        rm -f /mnt/backup/data/data_diff*
        #
        tar cfz "/mnt/backup/config/config_full_$6-$2-$3.tgz" $CONFIG
        rm -f /mnt/backup/config/config_diff*
else
        # incremental backup:
        #
        find $DATA -depth -type f \( -ctime -1 -o -mtime -1 \) -print > $LIST
        tar cfzT "/mnt/backup/data/data_diff_$6-$2-$3.tgz" "$LIST"
        rm -f "$LIST"
        #
        find $CONFIG -depth -type f  \( -ctime -1 -o -mtime -1 \) -print > $LIST
        tar cfzT "/mnt/backup/config/config_diff_$6-$2-$3.tgz" "$LIST"
        rm -f "$LIST"
fi

umount /mnt/backup
Hope this will help you in creating your own script.

Last edited by Satyaveer Arya; 12-23-2011 at 01:04 PM.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Backup only user created data thepalsrus Linux - Newbie 4 08-28-2009 02:54 PM
tar backup of an XP directory fof3 Linux - Newbie 2 03-31-2007 04:39 PM
User tar to create multiple backup files Canmetal Linux - General 3 03-24-2006 04:56 PM
dont want backup files to be created in mandrake 10.0 ranger225 Linux - Newbie 5 09-23-2004 05:36 PM
Using tar to backup a directory and subdirs n1wil Linux - General 1 08-07-2002 11:32 PM


All times are GMT -5. The time now is 04:53 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration