Hey.
What i want to do is use the output from find, diff and then pipe it to cpio. Somewhat like this
Code:
find . -print > homefolderMonday
find . -print > homefolderTuesday
diff homefolderMonday homefolderTuesday | cpio --create --format=newc > /mnt/backup/backup.cpio
Problem is that the output from diff can't be piped directly since the output contains other things in addition to the folder and file changes.
example:
2684a2685
> ./.kde/share/apps/kopete/msnpictures/someuserblabla-com.png
So how do i remove the "2684a2685" and ">" part from diff output? I'm also open for other ways to do this so if you have sugestions tell me.
I've made a basic backup utility that backups every users /home folders to a specified mounted partition. It works somewhat like this. PS, this is not the complete code. I can provide it if necesary.
Code:
#!/bin/bash
# What user should be backed up?
USER=Mogget
# Users home directory
USERHOME=/home/$USER
# Where to backup to
BACKUPDIR=/mnt/backup
# What date is it today?
DATE=`date -u +%m%d%y`
# Create users directory in backup directory?
CRTUSERDIR=0
# Create todays directory in users backup directory?
CRTUSERTODAY=0
# If 0 the backup process will be aborted after directory checking
DOBACKUP=0
if [ -d $BACKUPDIR/$USER ]; then
echo "$BACKUPDIR/$USER exist."
else
echo "Creating $BACKUPDIR/$USER."
mkdir $BACKUPDIR/$USER
fi
if [ -d $BACKUPDIR/$USER/$DATE.bak
echo "Backup already been done, exiting backup script."
DOBACKUP=1
else
echo "Creating $BACKUPDIR/$USER/$DATE.bak."
mkdir $BACKUPDIR/$USER/$DATE.bak
fi
if [ $DOBACKUP = "0" ]; then
cd $USERHOME
echo "Making a list of $USERHOME."
find . -print > $BACKUPDIR/$USER/$DATE.bak/$DATE.list
echo "Using $BACKUPDIR/$USER/$DATE.bak/$DATE.list to backup with cpio."
cat $BACKUPDIR/$USER/$DATE.bak/$DATE.list | cpio --create --format=newc > $BACKUPDIR/$USER/$DATE.bak/$DATE-backup.cpio
echo "Updating last update date in $BACKUPDIR/$USER/.last-backup."
date -u +%m%d%y > $BACKUPDIR/$USER/.last-backup
echo "Done backing up for today."
fi
The point of $BACKUPDIR/$USER/.last-backup is so that the script can retrieve the last backup list made so we can diff todays list and last backups list and run it through cpio
Any help and pointers will be gladly taken sorounding different ways to do this.
Thanks for the help in advance.