Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Compressing single file instead of whole directory
- #!/bin/sh
- # Where to backup to.
- mkdir -p /home/knoppix/backups --verbose
- dest="/home/knoppix/backups"
- # What to backup.
- cat /etc/passwd >> /home/knoppix/backups/dbusers.txt
- backupdb="/home/knoppix/backups/dbusers.txt"
- # Create archive filename.
- archive_file="DB$(date +%d%b%Y_%H%M).tgz"
- # Print start status message.
- echo "Backing up $backupdb to $dest/$archive_file"
- date
- echo
- # Backup the files using tar.
- tar czf $dest/$archive_file $backupdb
- #!/bin/sh
- # Where to backup to.
- mkdir -p /home/knoppix/backups --verbose
- dest="/home/knoppix/backups"
- # What to backup.
- cat /etc/passwd >> /home/knoppix/backups/dbusers.txt
- backupdir="/home/knoppix/backups"
- backupfile="dbusers.txt"
- # Create archive filename.
- archive_file="DB$(date +%d%b%Y_%H%M).tgz"
- # Print start status message.
- echo "Backing up $backupdb to $dest/$archive_file"
- date
- echo
- # Backup the files using tar.
- tar czf $dest/$archive_file -C $backupdir $backupfile
- #!/bin/sh
- # Where to backup to.
- mkdir -p /home/knoppix/backups --verbose
- dest="/home/knoppix/backups"
- # What to backup.
- cat /etc/passwd >> /home/knoppix/backups/dbusers.txt
- backupdir="/home/knoppix/backups"
- backupfile="dbusers.txt"
- # Create archive filename.
- archive_base_name="DB$(date +%d%b%Y_%H%M)"
- archive_file="$archive_base_name.tgz"
- # Print start status message.
- echo "Backing up $backupdb to $dest/$archive_file"
- date
- echo
- # Backup the files using tar.
- tar --transform="s#^$base#$archive_base_name#" czPf $dest/$archive_file $backupdb
- DB11Nov2011_0555/dbusers.txt
- tar --transform="s#dbusers#original#" xzf example.tgz # creates original.txt
- tar --transform="s#^#output/#" xzf example.tgz # creates output/dbusers.txt
- $ set -x
- $ archive_file="DB$(date +%d%b%Y_%H%M).tgz"
- ++ date +%d%b%Y_%H%M
- + archive_file=DB11Nov2011_0605.tgz
- $ echo $archive_file
- + echo DB11Nov2011_0605.tgz
- DB11Nov2011_0605.tgz
- $ set +x
- + set +x
- $ echo $archive_file
- DB11Nov2011_0605.tgz
- # Backup the files using tar.
- (cd /home/knoppix/backups/; tar czf $dest/$archive_file dbusers.txt)
Add Comment
Please, Sign In to add comment