Backups fail when the windows user name and folder have an apostrophe

Ran into the scenario where the user name has an apostrophe. When backing-up this error shows:


The username is something like The Guys's Place. The ’ is unescaped and causes an error on backup (verified manually in SSMS).

No backup is possible.

Escaping the ' with '' a backup is possible

This does NOT work:

BACKUP DATABASE TheGuysPlace TO DISK = 'C:\Users\The Guys's Place\Documents\SambaPOS5\Database Backups' WITH FORMAT, NAME = 'test'

This DOES work:

BACKUP DATABASE TheGuysPlace TO DISK = 'C:\Users\The Guys''s Place\Documents\SambaPOS5\Database Backups' WITH FORMAT, NAME = 'test'

Perhaps String.Replace("'", "''") on the path will fix this for others.

1 Like

Just a side no note that it’s best not to store database backups in the user folder, should use store elsewhere as SQL by default will not have access to user folders.

1 Like

It wont but the default location is the user folder and it will ask for permission to that folder on first install you can grant it by choosing yes from the popup in sambapos.

1 Like

Really? I’ve never seen that before

It does indeed ask that question. But as you said I save it in C drive folder instead.

At what point does it ask? I’ve fresh installed v5.3.0 a few times and not seen that. But also one of the first things I do is set it to another folder. I assume it doesn’t ask in the installer, so when exactly does it popup? Is it if you attempt a backup?

it’s when the first backup is attempted at the default folder location on a fresh install

1 Like

Yes it asks only for default location. You can make it blank in settings and it will reset to default location and the first attempt at a backup will trigger the prompt to give permission.

1 Like

I will try that to see it then, thanks.

When I do any setup, first thing I do is change the backup folder, hence why I never saw this. I guess it was added recently?

No it’s been there for a bit. I don’t remember exactly

1 Like