Competition: What’s your favorite Redgate tool? Enter now.

Command line to add scheduled backup

sandrogsandrog Posts: 3
edited August 28, 2007 8:39PM in SQL Backup Previous Versions
Is it possible to use a command line to add scheduled backup?

After our registration process we will automatically create a database for the user and we would like to also automatically create a job for a daily backup for that database?

How to do that?

thanks
Sandro

Comments

  • If all of your "user" database backups follow the same pattern (e.g. backup to the same location, same compression and encryption options), you can utilise the "BACKUP DATABASES EXCLUDE" syntax provided by SQL Backup.

    For example, if I have databases A, B, C and D, running "BACKUP DATABASES EXCLUDE [A, B]..." will backup C and D. If I add a new database E and perform the same command, it will backup C, D and E automatically.


    If you need more complicated behaviour, you would need to delve into the SQL Server Books Online, and in particular with job creation via Transact-SQL scripts... The following URL should give you a decent starting point: http://msdn2.microsoft.com/en-us/library/ms191450.aspx

    Once you've got the basic script, you would need a way to manipulate it to add the new database name etc, but it can be automated.

    Hope that helps,
    Jason
  • Your suggestion with EXCLUDE would work fine.

    Thanks a lot
Sign In or Register to comment.