Backup Commands


  1. Get status of tape device
    mt -f /dev/rmt/0m status

  2. Mount and rewind
    mt -f /dev/rmt/0m rewind

  3. Back up everything under /lawson ( Note: Does not follow symbolic links )
    find /lawson -depth -print | cpio -ocvB > /dev/rmt/0m

  4. Read the table of contents of the tape device
    cpio -idmBvt < /dev/rmt/0m > cpio.table 2>&1

  5. Get everything under /lawson from tape back to disk
    nohup cpio -icdmBv '/lawson/*' < /dev/rmt/0m 2>&1 &

  6. Monitor the progress of the above job
    tail -f nohup.out

  7. Get only some files back from tape
    cpio -icdmBv '/lawson/pdlib/*' '/lawson/system/ladb.cfg' < /dev/rmt/0m

  8. Find all files owned by user jdoe
    find / -user user jdoe -print 2>/dev/null

  9. Find all files owned byt UserID 227
    find / -uid 227 -print 2>/dev/null

  10. What files have changed in the last 7 hours?
    find / -ctime -7 -print

  11. What files have been modified in the last 7 hours
    find / -mtime -7 -print

  12. 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}'

  13. 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

  14. List all files of type Directory that are under the current directory
    find . -type d -print

  15. List all files of type File named nohup.out
    find . -type f -exec grep -ls nohup.out {} \;

  16. Prompt user before removing a file
    find / -name nohup.out -ok rm {} \;

  17. Case insensitive search
    find . -iname -print

  18. Find files under current directory named string.scr or string.prt
    find . \( -name "*.scr" -o -name "*.rpt" \) -print

  19. Search the whole system for core files, prompt user for deletion
    find / -name core -ok rm {} \;

  20. Search the whole system for files that end in 'log'
    find / -print 2>/dev/null | grep log\$

  21. Search the whole system for files that start with 'law'
    find / -print 2>/dev/null | grep \^law

  22. List all files changed within the last hour
    find . -ctime -1 -exec ls -l {} \; 2>/dev/null

  23. List that haven't been changed within the last year. Prompt user for deletion
    find . -ctime +$(print $((365*20))) -exec ls -l {} \; -ok rm {} \;

  24. Find all symbolic links
    find . -type -l -print
    find . -type -l -exec ls -l {} \;

  25. List all log files older than 30 days
    cd /var/backup/logs find . -mtime +30 -print

  26. Remove all log files older than 30 days
    find . -mtime +30 -print -exec rm {} \;

  27. List all log files older than 30 days, prompting before removal
    find . -mtime +30 -print -ok rm {} \;