Okay. I've come to the conclusion that I'll be using rsync for daily backups and tar for a full weekly backup.
But now that I'm testing my scripts I see that tar is doing it's job but rsync is only taking backups of some files. (would be alright if I already had a full backup but I don't) I was under the impression that rsync made sure that ALL files and folders in directory-A were copied to directory-B.
Right now I get a 11.5kb folder when using rsync on /home, but I get 153.2MB file using tar.
Code:
#!/bin/bash
# What to backup.
backup_files="/home"
# Backup destination.
dest="/media/temporary/usbbackup"
# Backup name.
date=$(date +%d-%m)
name=$"backup"
archive_file="$name-$date.tgz"
# Make backup using tar.
tar -cvpzf $dest/$archive_file $backup_files
# Find and delete old backups.
find . -name 'backup_*' -mtime +13 -delete
# Print end status message.
echo
echo "Backup finished"
date
# Long listing of files in $dest to check file sizes.
ls -lh $dest
So this is my almost final weekly backup script.
Since I'm a total noob I'd like inputs on if this will do what I want (you can read in the script what I think the commands do) . I've run it using terminal and it does backup. But I'm not able to see if the "Find and delete old backups" command works. Also I can't seem to find anything about naming the file anything other then the hostname or any kind of domainname, so I could use an input there. I want the file to be called "backup-date.tgz"
I've found how to name the file in script above and changed the appropriate section.
Still could use input on the "find and delete" command.
Code:
#!/bin/bash
#############################################
# ## ## #
# # # Syn # #
# ## # #
# # # ## #
#############################################
# What files to sync.
backup_files="/"
# Where to sync files.
dest="user@192.168.0.1:/user/backup"
Password:123
# Print status message.
echo
echo "Backup starting"
date
# Make backup using rsync.
rsync -azv -e ssh --delete $backup_files $dest
# Print end status message.
echo
echo "Backup finished"
date
This is my rsync script. Will this work? I don't have an ssh setup so I can't check.
Bookmarks