Backup Commands
- Get status of tape device
mt -f /dev/rmt/0m status
- Mount and rewind
mt -f /dev/rmt/0m rewind
- Back up everything under /lawson ( Note: Does not follow symbolic links )
find /lawson -depth -print | cpio -ocvB > /dev/rmt/0m
- Read the table of contents of the tape device
cpio -idmBvt < /dev/rmt/0m > cpio.table 2>&1
- Get everything under /lawson from tape back to disk
nohup cpio -icdmBv '/lawson/*' < /dev/rmt/0m 2>&1 &
- Monitor the progress of the above job
tail -f nohup.out
- Get only some files back from tape
cpio -icdmBv '/lawson/pdlib/*' '/lawson/system/ladb.cfg' < /dev/rmt/0m
- Find all files owned by user jdoe
find / -user user jdoe -print 2>/dev/null
- Find all files owned byt UserID 227
find / -uid 227 -print 2>/dev/null
- What files have changed in the last 7 hours?
find / -ctime -7 -print
- What files have been modified in the last 7 hours
find / -mtime -7 -print
- What files are on the system that are >= 100 kilo bytes?
find . -size +100k -exec ls -l {} \; | awk '{print $9, $5}'
find . -size +100k -exec ls -l {} \; | awk '{printf $9, $5}'
- Same as above but sort the output numerically by the first field
find . -size +100k -exec ls -l {} \; | awk '{printf "%40s %10s \n", $9, $5}' | sort -n +1
- List all files of type Directory that are under the current directory
find . -type d -print
- List all files of type File named nohup.out
find . -type f -exec grep -ls nohup.out {} \;
- Prompt user before removing a file
find / -name nohup.out -ok rm {} \;
- Case insensitive search
find . -iname -print
- Find files under current directory named string.scr or string.prt
find . \( -name "*.scr" -o -name "*.rpt" \) -print
- Search the whole system for core files, prompt user for deletion
find / -name core -ok rm {} \;
- Search the whole system for files that end in 'log'
find / -print 2>/dev/null | grep log\$
- Search the whole system for files that start with 'law'
find / -print 2>/dev/null | grep \^law
- List all files changed within the last hour
find . -ctime -1 -exec ls -l {} \; 2>/dev/null
- List that haven't been changed within the last year. Prompt user for deletion
find . -ctime +$(print $((365*20))) -exec ls -l {} \; -ok rm {} \;
- Find all symbolic links
find . -type -l -print
find . -type -l -exec ls -l {} \;
- List all log files older than 30 days
cd /var/backup/logs
find . -mtime +30 -print
- Remove all log files older than 30 days
find . -mtime +30 -print -exec rm {} \;
- List all log files older than 30 days, prompting before removal
find . -mtime +30 -print -ok rm {} \;
|