If you want to make a backup of all your databases, run this script. This script excludes the system databases. Set your backup path accordingly.
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
-- specify database backup directory
SET @path = 'E:\backup\'
-- specify filename format
SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112)
DECLARE db_cursor CURSOR READ_ONLY FOR
SELECT name
FROM master.dbo.sysdatabases
WHERE name NOT IN ('master','model','msdb','tempdb') -- exclude these databases
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @name
WHILE @@FETCH_STATUS = 0
BEGIN
SET @fileName = @path + @name + '_' + @fileDate + '.BAK'
BACKUP DATABASE @name TO DISK = @fileName
FETCH NEXT FROM db_cursor INTO @name
END
CLOSE db_cursor
DEALLOCATE db_cursor
8 February 2018
7 February 2018
APACHE - Accessing multiple domain names using port 80
If you plan to publish 2 or more domain urls from the same apache server, this configuration will help you but the requirement is the document root path should be different for all domains.
<VirtualHost *:80>
ServerName my-server1.com
DocumentRoot /var/www/html/my-app1
<Directory /var/www/html/my-app1>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName my-server2.com
DocumentRoot /var/www/html/my-app2
<Directory /var/www/html/my-app2>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName my-server3.com
DocumentRoot /var/www/html/my-app3
<Directory /var/www/html/my-app3>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName my-server1.com
DocumentRoot /var/www/html/my-app1
<Directory /var/www/html/my-app1>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName my-server2.com
DocumentRoot /var/www/html/my-app2
<Directory /var/www/html/my-app2>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName my-server3.com
DocumentRoot /var/www/html/my-app3
<Directory /var/www/html/my-app3>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
APACHE - Reverse Proxy using root (/)
This took me days to figure out. I am happy to share with you guys who are wondering how to setup a reverse proxy.
<VirtualHost *:8081>
ServerName my-server
DocumentRoot /var/www/html/my-app
RewriteEngine On
<Directory /var/www/html/my-app/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://{internal-app-server-ip}/
ProxyPassReverse / http://{internal-app-server-ip}/
</VirtualHost>
Save it and restart apache service.
When you access http://my-server:8081 in a browser apache will interpret the configuration above and redirects the url to http://{internal-app-server-ip}/ - internally while preserving the originating url in your browser which is http://my-server:8081.
<VirtualHost *:8081>
ServerName my-server
DocumentRoot /var/www/html/my-app
RewriteEngine On
<Directory /var/www/html/my-app/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://{internal-app-server-ip}/
ProxyPassReverse / http://{internal-app-server-ip}/
</VirtualHost>
Save it and restart apache service.
When you access http://my-server:8081 in a browser apache will interpret the configuration above and redirects the url to http://{internal-app-server-ip}/ - internally while preserving the originating url in your browser which is http://my-server:8081.
APACHE - If application path differs from DocumentRoot
If you are given a requirement where the application path does not reside in the default DocumentRoot defined in the apache config, then do this.
Define your Alias in httpd.conf. This is done in Apache on Windows server which is similar
if you are on Linux server - need to define your path accordingly.
Alias "/{app-name}" "C:\{app-path}"
<Directory "C:\{app-path}">
Require all granted
</Directory>
Save it and restart apache services.
Define your Alias in httpd.conf. This is done in Apache on Windows server which is similar
if you are on Linux server - need to define your path accordingly.
Alias "/{app-name}" "C:\{app-path}"
<Directory "C:\{app-path}">
Require all granted
</Directory>
Save it and restart apache services.
APACHE - Redirect URL containing an IP address to domain name
[On]
Red Hat Enterprise Linux Server release 7.4 (Maipo)
Please insert the Rewrite conditions as follows in the .htaccess file located in your DocumentRoot directory.
--- Change the IPs accordingly. ---
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^10\.24\.19\.85$ [OR]
RewriteCond %{HTTP_HOST} ^10\.24\.19\.109$
RewriteRule ^(.*)$ https://{DOMAIN_NAME}/$1 [L,R=301]
</IfModule>
Red Hat Enterprise Linux Server release 7.4 (Maipo)
Please insert the Rewrite conditions as follows in the .htaccess file located in your DocumentRoot directory.
--- Change the IPs accordingly. ---
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^10\.24\.19\.85$ [OR]
RewriteCond %{HTTP_HOST} ^10\.24\.19\.109$
RewriteRule ^(.*)$ https://{DOMAIN_NAME}/$1 [L,R=301]
</IfModule>
6 February 2018
AIX - To clear print queue and restart qdaemon
# enq -sAW
# ps -eaf | grep {queue name}
# kill -9 {queue name}
# cd /var/spool/lpd/qdir
# remove all queues
# cd /var/spool/lpd/stat
# remove the specified queue entry
# stopsrc -s qdaemon
# startsrc -s qdaemon
# ps -eaf | grep {queue name}
# kill -9 {queue name}
# cd /var/spool/lpd/qdir
# remove all queues
# cd /var/spool/lpd/stat
# remove the specified queue entry
# stopsrc -s qdaemon
# startsrc -s qdaemon
ORACLE - Kill session
You plan to work on a schema or to drop a schema and Oracle throws you a warning saying Schema is in use. What do you do?
SQL> select sid, serial# from v$session where username='{your-schema}';
Please observe the sid, serial# from the output, then proceed to kill the session with
SQL> alter system kill session 'sid,serial#';
You can rerun the select statement again to verify the specific schema has been removed.
Subscribe to:
Posts (Atom)
Wordpress - Local installation in Vmware
If you're interested in exploring website design with WordPress, this guide will help you set up a WordPress instance on your local mach...
-
To print single column from a text file #awk -F: '{print $1}' /etc/passwd To print multiple columns from a text file # awk -F: '...
-
[Tested On] CentOS Linux release 7.4.1708 (Core) # wget https://ftp.postgresql.org/pub/source/v9.6.6/postgresql-9.6.6.tar.gz # tar xvzf post...
-
Your new IT project requires you to setup postgresql database and most of the time we get to the postgresql website and download the version...