Showing posts with label administration. Show all posts
Showing posts with label administration. Show all posts

Tuesday, June 30, 2015

Scripted backup of all SQL Server DB's

This is a handy script to backup all or specified DB's to disk with data stamps and environment in the filename.

Thanks Greg Robidoux!
Original ref: http://www.mssqltips.com/sqlservertip/1070/simple-script-to-backup-all-sql-server-databases/


--Simple script to backup all SQL Server databases
--http://www.mssqltips.com/sqlservertip/1070/simple-script-to-backup-all-sql-server-databases/

DECLARE @name VARCHAR(50) -- database name  
DECLARE @path VARCHAR(256) -- path for backup files  
DECLARE @fileName VARCHAR(256) -- filename for backup  
DECLARE @fileDate VARCHAR(20) -- used for file name

DECLARE @env VARCHAR(20) = 'Local'

-- specify database backup directory
SET @path = 'C:\Backup\'

-- specify filename format
SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112) 
print @fileDate

DECLARE db_cursor CURSOR FOR  
SELECT name FROM master.dbo.sysdatabases  WHERE name NOT IN ('master','model','msdb','tempdb','ReportServer','ReportServerTempDB')  -- Exclude these databases
--SELECT name FROM master.dbo.sysdatabases  WHERE name IN ('MyDB1','MyDB2','MyDB3')  -- Or, only include these databases

OPEN db_cursor   
FETCH NEXT FROM db_cursor INTO @name   

WHILE @@FETCH_STATUS = 0   
BEGIN   
       SET @fileName = @path + @name + '_' + @env + '_' + @fileDate + '.bak'  
       print 'Backing up ' + @name + ' to ' + @fileName  
       
       BACKUP DATABASE @name TO DISK = @fileName
       
       print 'Finished ' + @name
       FETCH NEXT FROM db_cursor INTO @name   
END   

CLOSE db_cursor   
DEALLOCATE db_cursor

Tuesday, July 15, 2014

Setting up an FTP server on CentOS 6.x

Need FTP access on a CentOS machine? Easy.

sudo yum install vsftpd
sudo service vsftpd start
sudo chkconfig vsftpd on
chkconfig --list

sudo vi /etc/vsftpd/vsftpd.conf # edit default conf file to have these lines:
    anonymous_enable=NO
    chroot_local_user=YES
    chroot_list_enable=NO
    chroot_list_file=/etc/vsftpd/chroot_list
    pasv_min_port=3000
    pasv_max_port=3050
   
sudo touch /etc/vsftpd/chroot_list
sudo /sbin/service vsftpd restart


Done.

Note that these steps have been grabbed from this Rackspace article that includes much more detail:
http://www.rackspace.com/knowledge_center/article/rackspace-cloud-essentials-centos-installing-vsftpd