Linux/SimpleBashBackup: Difference between revisions
< Linux
Line 40: | Line 40: | ||
</pre> | </pre> | ||
=== multiple folders === | === multiple folders === | ||
=== clean old backups === | === clean old backups === | ||
<pre> | <pre> | ||
Line 53: | Line 60: | ||
</pre> | </pre> | ||
=== mount / unmount samba share === | === mount/unmount samba share === | ||
* /root/.smb_cred | * /root/.smb_cred | ||
<pre> | <pre> | ||
Line 59: | Line 66: | ||
password=password1234 | password=password1234 | ||
</pre> | </pre> | ||
* 70_mountcifs.job: | |||
<pre> | <pre> | ||
mount -t cifs -o credentials=/root/.smb_cred //sambaserver/sambashare /mnt/localmountpoint | mount -t cifs -o credentials=/root/.smb_cred //sambaserver/sambashare /mnt/localmountpoint | ||
</pre> | </pre> | ||
* 71_remotework.job | |||
* 72_remotework.job | |||
* 73_unmountcifs.job: | |||
<pre> | <pre> | ||
umount -l /mnt/localmountpoint | umount -l /mnt/localmountpoint | ||
</pre> | </pre> | ||
=== mysql databases === |
Revision as of 17:22, 3 June 2016
default folder structure
/srv /backup /backupmanager.sh /01_daily-jobs /02_weekly-jobs /03_monthly-jobs /templates /tmp /backup-data /01_daily /02_weekly /03_monthly
backupmanager.sh
example jobs
- each job file needs to be located in one of the job folders (01_daily-jobs, 02_weekly-jobs, 03_monthly-jobs)
- each job file needs to end in .job
- the following variables are passed on from the main script
- BACKUPDIR -> path where the backupfile should be placed (e.g. /srv/backup-data/01_daily/2016-05-23)
- FILEDESC -> datecode to be used in the filename
- TEMPDIR -> can optionally be used for temp files
single folder
weak compression
ARCHIV="$BACKUPDIR/${FILEDESC}_server_srv_www.tar.gz" tar -c /srv/www | pigz --best > $ARCHIV
strong compression
ARCHIV="$BACKUPDIR/${FILEDESC}_server_srv_www.tar.7z" tar -c /srv/www | 7z a -m0=lzma2 -mx9 -si $ARCHIV
multiple folders
clean old backups
KEEP="4" cd $BACKUPDIR cd .. ls -r | sed -e 1,${KEEP}d | xargs rm -r
rsync backup files to other server
rsync -avz -e ssh $BACKUPDIR username@hostnameoftarget:/srv/backup-data/targetfolder
- /root/.smb_cred
username=testuser password=password1234
- 70_mountcifs.job:
mount -t cifs -o credentials=/root/.smb_cred //sambaserver/sambashare /mnt/localmountpoint
- 71_remotework.job
- 72_remotework.job
- 73_unmountcifs.job:
umount -l /mnt/localmountpoint