<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://kb.owrench.com/index.php?action=history&amp;feed=atom&amp;title=Auto_backups_setup_%28DB%29</id>
	<title>Auto backups setup (DB) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://kb.owrench.com/index.php?action=history&amp;feed=atom&amp;title=Auto_backups_setup_%28DB%29"/>
	<link rel="alternate" type="text/html" href="http://kb.owrench.com/index.php?title=Auto_backups_setup_(DB)&amp;action=history"/>
	<updated>2026-05-04T04:26:33Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>http://kb.owrench.com/index.php?title=Auto_backups_setup_(DB)&amp;diff=134&amp;oldid=prev</id>
		<title>imported&gt;Kishor at 04:31, 3 January 2018</title>
		<link rel="alternate" type="text/html" href="http://kb.owrench.com/index.php?title=Auto_backups_setup_(DB)&amp;diff=134&amp;oldid=prev"/>
		<updated>2018-01-03T04:31:14Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This page explains the steps to be carried out once a new application is setup and it's database needs to be backed up daily. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1.&amp;lt;/b&amp;gt; Put the backup script in the live server depending on whether it's a postgres or mysql db and add a cron to run it daily. &amp;lt;br&amp;gt;&lt;br /&gt;
Example script: &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;current_time=$(date &amp;quot;+%d-%m-%Y_%H:%M&amp;quot;); &amp;lt;br&amp;gt;&lt;br /&gt;
pg_dump -U ddugky_dbuser -h localhost -Ft ddugky_db2 -n public -x -O -f &amp;quot;mis.ddugky.co.in/databasebackup/ddugkymis_$current_time&amp;quot;.&amp;quot;tar&amp;quot;; &amp;lt;br&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2.&amp;lt;/b&amp;gt; Now, creata a ftp user whose home directory is the backup folder. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3.&amp;lt;/b&amp;gt; Now, we need to create a script in our local system to download this backup file automatically. &amp;lt;br&amp;gt;&lt;br /&gt;
To do that, &amp;lt;br&amp;gt;&lt;br /&gt;
Create a new shell script file (say, appname_db.sh) inside /home/origami/backupscripts/ folder &amp;lt;br&amp;gt;&lt;br /&gt;
Example content,  &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;#!/bin/bash &amp;lt;br&amp;gt;&lt;br /&gt;
HOST='107.161.191.186' #IP Address of the remote server &amp;lt;br&amp;gt;&lt;br /&gt;
USER='dbbmis@mis.ddugky.co.in'    #Username of ftp &amp;lt;br&amp;gt;&lt;br /&gt;
PASSWORD='WvloVGFK3BMys' #Password of ftp &amp;lt;br&amp;gt;&lt;br /&gt;
REMOTEFILENAME=&amp;quot;ddugkymis_$(date +%d-%m-%Y)_*&amp;quot; #File name of backup file in server ddugkymis_01-01-2018_00:00.tar &amp;lt;br&amp;gt;&lt;br /&gt;
LOCALDIR=&amp;quot;Ddugky&amp;quot; &amp;lt;br&amp;gt;&lt;br /&gt;
. downloadfile.sh &amp;lt;br&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4.&amp;lt;/b&amp;gt; Now add the new above created file to the list of applications that are backed up daily. To do that,  &amp;lt;br&amp;gt;&lt;br /&gt;
Open downloadfile.sh in the same folder and add &amp;quot;. appname_db.sh&amp;quot; without quotes, to the last line. Save the file.  &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The backup will be downloaded automatically from the next day, once the cron runs. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Note: make sure the backup file name format in the remote server and the script in local machine are same, otherwise the script will fail to find the file in the remote server. &amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:it-support]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Kishor</name></author>
		
	</entry>
</feed>