top of page
  • Twitter Social Icon
  • Facebook Social Icon
  • LinkedIn Social Icon

Change default backup directory in SQL Server on Linux

  • Obrázek autora: Filip Holub
    Filip Holub
  • 15. 2. 2019
  • Minut čtení: 1

When we have the installation of SQL Server on Linux done, location for backup files is here /var/opt/mssql/data, by default. In this demo, I will show you how to change this location by filelocation.defaultbackupdir. It is useful for each distribution of Linux, such as Ubutnu, RHEL or SUSE. Let's get start!


"First of all, you have to connect as root user on your Linux machine!"

  • Now, we can check default folder for backup (.BAK, TRN) files via Management studio:


The next step is that I will create a new dedicated folder for backup files, by following commands:

  • pwd - Return the name of working directory

  • cd /var/opt/mssql/data - Means "Change Directory", change current working directory.

  • sudo mkdir backup - mkdir means "make directory", which is command for create new directory, that's all. We created backup for our .bak files.

  • ls -l | grep backup - ls -l means list directories and files, grep files just filters name of files.

Right now, we have to grant permission for mssql user, which was creted with installation of SQL Server, run following comands:

  • sudo chown mssql /var/opt/mssql/data/backup - It is for change owner of directories and files. - For our backup directory.

  • sudo chgrp mssql /var/opt/mssql/data/backup - It is for change group of directories and files. - For our backup directory.


 

Finally, we can change default backup directory in SQL Server by following commands:

and provide restart of SQL Server.

And that's all. If you want to be sure, you can check again via Management Studio:

Default location for backup has been changed successfully.
Default location for backup has been changed successfully.

I hope you save our time!

SIGN UP AND STAY UPDATED!
  • Grey Twitter Icon
  • Grey Facebook Icon
  • Grey LinkedIn Icon

© 2020 All rights reserved. MSSQLONLINUX.com | Filip Holub

bottom of page