I wrote a script a day ago that backs up my entire database and all of my /var/www files to a network share. It was my first try at scripting in Linux and all in all I think it is really cool. I would like to add a feature to my backup script. Currently, the script uses rsync to overwrite any existing data on the destination for the backup. I would like it actually create a unique, full backup, every time it runs. Right now I have it running every night at midnight. However, I only want to have 15 concurrent full backups at a time - so once it hits 15 backups I want it to start deleting the older backups. Can anyone point me in the right direction?
Here's my current script:
#!/usr/bin/env bash
# Mount the share
smbmount //address/folder /mnt/folder -o credentials=/root/.smbpasswd
# Synchronize the Web folder
rsync --delete -C -v -a -r /var/www /mnt/folder
# Create a backup of all databases
mysqldump -uuser -ppassword --all-databases | gzip -9 > /root/backup/Databases.sql.zip
# Copy the backup to the backup folder
cp /root/backup/Databases.sql.zip /mnt/folder/Databases.sql.zip
echo "Backup complete!"