0

I am looking to make an archive of my root directory, but only certain folders/files. So far, this is what I have, can you please tell me what I'm doing wrong? For the purposes of figuring out the issue, I've got 3 test files (test1, etc) in the /home/user directory that I'm trying to archive with cpio, with the folder name being the date. Bear with me, as I'm fairly new at this. Thanks.

today="$(date +%m%d%Y)"

mkdir /home/user/backuptest/$today

LIST="test1 test2 test3"

for i in $LIST

do

find $i -print | cpio -pduv /home/user ;

find $i -print | cpio -pduv /home/user/backuptest/$today

done

koo
  • 23
  • 3

1 Answers1

0

Excerpts of my home backup script, for what it's worth:

set DIRS = "/etc /root /usr/home /usr/local/etc"
set TMPFILE = /tmp/tar-`date "+%F_%T"`.tmp
set FILENAME = /backup/backup-`hostname -s`_`date "+%F"`.tbz

# Build list of files to be backed up
foreach LOCATION ($DIRS)
    find $LOCATION -type fl >> $TMPFILE
end

# Do actual backup
tar cyfTP - $TMPFILE | dd bs=10k of=$FILENAME

# Cleanup list of files
rm -f $TMPFILE

Note: There's a lot of round about ways of doing things in there because I actually pipe the archive through LZMA Compression, Blowfish Encryption, Full/Incremental/Differential Backups, and write to either File or Tape.

Chris S
  • 77,337
  • 11
  • 120
  • 212
  • This leads me to my next question...I continuously receive the "cpio: cannot open file" error, even though I have full permission over them. Thanks – koo Jul 06 '11 at 16:51
  • A guess, you've got directories in there and `find` will print them by default if you don't add `-type fl` arguments. – Chris S Jul 06 '11 at 17:00
  • It still seems to be pushing out the "permission denied, can't open" error. I removed -print and just put -type f, and it is still returning that message. (-type fl returned "type arg must be 1 character) Thanks – koo Jul 06 '11 at 17:47
  • What OS is this exactly? – Chris S Jul 06 '11 at 19:21
  • Hi, this is on an Ubuntu server, but I've figured out the permission issue. Thanks – koo Jul 07 '11 at 14:09