Sponsored Content
Special Forums Hardware Filesystems, Disks and Memory Can I back up all the files I work with each day using tar? Post 302091297 by hegemaro on Sunday 1st of October 2006 10:25:41 AM
Old 10-01-2006
Yes you can. Use the find(1) command to generate a list of files that have been modified in the last day and use that as input to the tar(1) command. Let's assume you're in your home directory:

$ mkdir backup
$ tar cvf backup/20061001.tar `find . -type f -mtime -1 -print`


If you run this command multiple times in a day, it could find your previous backups, so you might add a grep(1) filter to remove your backups:

$ tar cvf backup/20061001.tar `find . -type f -mtime -1 -print | grep -v "^./backup/"`
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

tar to tape and back

Howdy, I'm trying to tar some directories to tape and then extract them from tape on another machine. I was hoping someone could help me with the syntax of the tar commands. Both machines are running Solaris 8. Need to get all files and directories under the following: ... (6 Replies)
Discussion started by: pmetal
6 Replies

2. UNIX for Dummies Questions & Answers

Need to go back 1 day using the date command

I am trying to write a shell script to look at log files with dates in the file name. Now I know how to use the expr command to subtract 1 day from the other, which is simple when the dates are from the 2nd to the 31st of each month. But the problem I have is when the date turns to the 1st... (4 Replies)
Discussion started by: cfoxwell
4 Replies

3. AIX

tar -xvf doesnt work

Hello Im trying to extract this file tar -xvf opt-samba-base.tar.tar tar: 0511-169 A directory checksum error on media; 0 not equal to 75420. but I get that message I tried algo with gunzip and uncompress but nothing happens gunzip -d opt-samba-base.tar.tar gunzip:... (2 Replies)
Discussion started by: lo-lp-kl
2 Replies

4. Shell Programming and Scripting

to find all files created a day back

Hi Guys, My unix is SunOS. I like to find all the files which are created 1 day back. i tried the following command find . -type f -name '*.aud' -mtime +1 This gives me all the files created 48 hours back (2 days) but not one.. Can you let me know where i am going wrong. Thanks,... (8 Replies)
Discussion started by: mac4rfree
8 Replies

5. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

6. UNIX for Dummies Questions & Answers

tar xzCf --mode doesn't work.

$ touch x y $ ls -l x y -rw-r--r-- 1 g660 0 Sep 26 03:38 x -rw-r--r-- 1 g660 0 Sep 26 03:38 y $ chmod 777 x y $ ls -l x y -rwxrwxrwx 1 g660 0 Sep 26 03:38 x -rwxrwxrwx 1 g660 0 Sep 26 03:38 y $ rm a.tar $ tar cvzf a.tar.gz . ./ ./x ./y ./a.tar.gz $ ls -l total 4 -rw-r--r-- 1 ... (3 Replies)
Discussion started by: volbod
3 Replies

7. UNIX for Dummies Questions & Answers

Move the files between Current day & a previous day

Hi All, I have a requirement where I need to first capture the current day & move all the files from a particular directory based on a previous day. i.e move all the files from one directory to another based on current day & a previous day. Here is what I am trying, but it gives me errors.... (2 Replies)
Discussion started by: dsfreddie
2 Replies

8. Shell Programming and Scripting

Back up log files using tar

Hi, I need some help writing a perl script to tar all log file to a directory and then delete the log files. Can some one please help me on this? I m Not very good with perl scripting... Thanks KK (4 Replies)
Discussion started by: karthikk0508
4 Replies
chroot(1M)						  System Administration Commands						chroot(1M)

NAME
chroot - change root directory for a command SYNOPSIS
/usr/sbin/chroot newroot command DESCRIPTION
The chroot utility causes command to be executed relative to newroot. The meaning of any initial slashes (/) in the path names is changed to newroot for command and any of its child processes. Upon execution, the initial working directory is newroot. Notice that redirecting the output of command to a file, chroot newroot command >x will create the file x relative to the original root of command, not the new one. The new root path name is always relative to the current root. Even if a chroot is currently in effect, the newroot argument is relative to the current root of the running process. This command can be run only by the super-user. RETURN VALUES
The exit status of chroot is the return value of command. EXAMPLES
Example 1 Using the chroot Utility The chroot utility provides an easy way to extract tar files (see tar(1)) written with absolute filenames to a different location. It is necessary to copy the shared libraries used by tar (see ldd(1)) to the newroot filesystem. example# mkdir /tmp/lib; cd /lib example# cp ld.so.1 libc.so.1 libcmd.so.1 libdl.so.1 libsec.so.1 /tmp/lib example# cp /usr/bin/tar /tmp example# dd if=/dev/rmt/0 | chroot /tmp tar xvf - ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
cd(1), tar(1), chroot(2), ttyname(3C), attributes(5) NOTES
Exercise extreme caution when referencing device files in the new root file system. References by routines such as ttyname(3C) to stdin, stdout, and stderr will find that the device associated with the file descriptor is unknown after chroot is run. SunOS 5.11 15 Dec 2003 chroot(1M)
All times are GMT -4. The time now is 06:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy