I have a rather large music collection, about 3,5TB. So i do not want to lose all my thumbnails and settings.
I therefore created an automatic backup script i'd like to share if anyone else needs it.
I'm running Ubuntu Server but it runs fine on any Linux machine.
You need a mounted cifs or smb share. You can automatically mount the share every time your server starts by editing the /etc/fstab with:
- Code: Select all
sudo nano /etc/fstab
Then add the following at the bottom line, replace **** with username and password and replace //IP_TO_BACKUP_LOCATION/Backupfolder_Subsonic with your backup location.
- Code: Select all
//IP_TO_BACKUP_LOCATION/Backupfolder_Subsonic /mnt/backup cifs username=****,password=****
Create the script in /bin/execute/scripts/ with
- Code: Select all
sudo nano /bin/execute/scripts/backupsubsonic.sh
Then paste the following rows:
Change the username to your actual username.
This will basically zip your installation and put it in a folder with today's date. If you just want one copy, just replace the "Subsonic $(date +%F)" with "Subsonic"
- Code: Select all
tar -zcf /home/username/backup.tgz /var/subsonic
/bin/mkdir /mnt/backup/"Subsonic $(date +%F)"
/bin/cp -r /home/username/backup.tgz /mnt/backup/"Subsonic $(date +%F)"
rm /home/username/backup.tgz
Now to run the script automatically you need do the following:
- Code: Select all
sudo crontab -e
Then paste:
This will run every day at 01:01. More information about cron http://en.wikipedia.org/wiki/Cron
- Code: Select all
01 01 * * * /bin/sh /bin/execute/scripts/backupsubsonic.sh >/dev/null 2>&1
EDIT: If anyone wants help with the same this on a Windows machine i'd be happy to help.
Hopefully this will help someone out. If i can i'll be happy to answer any questions.