Difference between revisions of "Make copy of file and copy to Server"

From rbachwiki
Jump to navigation Jump to search
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
<h4 class="yellowbackground">sb222.sh </h4>
<pre>
<pre>
#!/bin/bash
#!/bin/bash
Line 22: Line 22:
     - name: make a backup copy of sqlite file
     - name: make a backup copy of sqlite file
       copy:
       copy:
         src: /mnt/c/Users/sales/Dropbox (Personal)/All Folders/websites/linode_msites/sb222/datab/sqLite_karaoke.sql
         src: /mnt/c/Users/sales/Dropbox (Personal)/All Folders/websites/msites/sb222/datab/sqLite_karaoke.sql
         dest: /mnt/c/Users/sales/Dropbox (Personal)/All Folders/websites/linode_msites/sb222/datab/sqLite_karaoke_backup.sql
         dest: /mnt/c/Users/sales/Dropbox (Personal)/All Folders/websites/msites/sb222/datab/sqLite_karaoke_backup.sql
</pre>
</pre>
<h4 class="bluebackground">cplocal.yml</h4>
<h4 class="bluebackground">cplocal.yml</h4>
Line 34: Line 34:
     - name: copy file sql file to local webfolder
     - name: copy file sql file to local webfolder
       copy:
       copy:
       src: /mnt/c/Users/bacchas/Dropbox (Personal)/Filing Cabinet/Karaoke Stuff/sqlitedb/sqLite_karaoke.sql
       src: /mnt/c/Users/sales/Dropbox (Personal)/Filing Cabinet/Stuff/sqlitedb/sqLite_karaoke.sql
       dest: /mnt/c/Users/bacchas/Dropbox (Personal)/All Folders/websites/linode_msites/rb222/database/
       dest: /mnt/c/Users/sales/Dropbox (Personal)/All Folders/websites/msites/rb222/database/
</pre>
</pre>
<h4 class="bluebackground">copytorb222.yml</h4>
<h4 class="bluebackground">copytosb222.yml</h4>
'''The host file contains the website info'''
<pre>
<pre>
---
---
- name: copy file to rb222
- name: copy file to mywebsite
   hosts: msites
   hosts: msites


Line 46: Line 47:
     - name: copy file
     - name: copy file
       copy:
       copy:
       src: /mnt/c/Users/bacchas/Dropbox (Personal)/Filing Cabinet/Karaoke Stuff/sqlitedb/sqLite_karaoke.sql
       src: /mnt/c/Users/sales/Dropbox (Personal)/Filing Cabinet/Stuff/sqlitedb/sqLite_karaoke.sql
       dest: /var/www/html/rb222/database/
       dest: /var/www/html/sb222/database/
</pre>
<h4 class="bluebackground">hosts</h4>
<pre>
rasberry ansible_ssh_host=192.168.21.6
[synology]
192.168.20.1
 
[mac]
192.168.20.11
 
[opilocal]
10.21.22.40
 
[client]
10.1.91.46
 
[msites]
10.14.25.23
 
[webserver]
server1 ansible_ssh_host=10.16.21.22
 
[fileserver]
server2 ansible_ssh_host=10.25.29.9
 
 
# This is the default ansible 'hosts' file.
#
# It should live in /etc/ansible/hosts
#
#  - Comments begin with the '#' character
#  - Blank lines are ignored
#  - Groups of hosts are delimited by [header] elements
#  - You can enter hostnames or ip addresses
#  - A hostname/ip can be a member of multiple groups
 
# Ex 1: Ungrouped hosts, specify before any group headers:
 
## green.example.com
## blue.example.com
## 192.168.100.1
## 192.168.100.10
 
# Ex 2: A collection of hosts belonging to the 'webservers' group:
 
## [webservers]
## alpha.example.org
## beta.example.org
## 192.168.1.100
## 192.168.1.110
 
# If you have multiple hosts following a pattern, you can specify
# them like this:
 
## www[001:006].example.com
 
# Ex 3: A collection of database servers in the 'dbservers' group:
 
## [dbservers]
##
## db01.intranet.mydomain.net
## db02.intranet.mydomain.net
## 10.25.1.56
## 10.25.1.57
 
# Here's another example of host ranges, this time there are no
# leading 0s:
 
## db-[99:101]-node.example.com
</pre>
</pre>
==[[Main_Page| Home]] - [[Scripts_used_on_Servers|Category]]==
[[Category:bash]][[Category:Ansible]]

Latest revision as of 15:55, 15 June 2023

sb222.sh

#!/bin/bash
clear
echo -e " +++++ Making a backup copy of sql file in the web folder ++++++++++++++++ \n"
ansible-playbook /etc/ansible/playbook/backupsqlfirst.yml
sleep 5
echo -e "++++++++++ Copying to local web folder ++++++++++++++ \n"
ansible-playbook /etc/ansible/playbook/cplocal.yml
sleep 5
ansible-playbook  /etc/ansible/playbook/copytorb222.yml --private-key ~/.ssh/ansible
echo "+++++         Done            ++++++"

backupsqlfirst.yml

---
- name: make backup copy of sql file
  hosts: localhost

  tasks:
    - name: make a backup copy of sqlite file
      copy:
        src: /mnt/c/Users/sales/Dropbox (Personal)/All Folders/websites/msites/sb222/datab/sqLite_karaoke.sql
        dest: /mnt/c/Users/sales/Dropbox (Personal)/All Folders/websites/msites/sb222/datab/sqLite_karaoke_backup.sql

cplocal.yml

---
- name: copy for db to web folder
  hosts: localhost

  tasks:
    - name: copy file sql file to local webfolder
      copy:
       src: /mnt/c/Users/sales/Dropbox (Personal)/Filing Cabinet/Stuff/sqlitedb/sqLite_karaoke.sql
       dest: /mnt/c/Users/sales/Dropbox (Personal)/All Folders/websites/msites/rb222/database/

copytosb222.yml

The host file contains the website info

---
- name: copy file to mywebsite
  hosts: msites

  tasks:
    - name: copy file
      copy:
       src: /mnt/c/Users/sales/Dropbox (Personal)/Filing Cabinet/Stuff/sqlitedb/sqLite_karaoke.sql
       dest: /var/www/html/sb222/database/

hosts

rasberry ansible_ssh_host=192.168.21.6
[synology]
192.168.20.1

[mac]
192.168.20.11

[opilocal]
10.21.22.40

[client]
10.1.91.46

[msites]
10.14.25.23

[webserver]
server1 ansible_ssh_host=10.16.21.22

[fileserver]
server2 ansible_ssh_host=10.25.29.9


# This is the default ansible 'hosts' file.
#
# It should live in /etc/ansible/hosts
#
#   - Comments begin with the '#' character
#   - Blank lines are ignored
#   - Groups of hosts are delimited by [header] elements
#   - You can enter hostnames or ip addresses
#   - A hostname/ip can be a member of multiple groups

# Ex 1: Ungrouped hosts, specify before any group headers:

## green.example.com
## blue.example.com
## 192.168.100.1
## 192.168.100.10

# Ex 2: A collection of hosts belonging to the 'webservers' group:

## [webservers]
## alpha.example.org
## beta.example.org
## 192.168.1.100
## 192.168.1.110

# If you have multiple hosts following a pattern, you can specify
# them like this:

## www[001:006].example.com

# Ex 3: A collection of database servers in the 'dbservers' group:

## [dbservers]
##
## db01.intranet.mydomain.net
## db02.intranet.mydomain.net
## 10.25.1.56
## 10.25.1.57

# Here's another example of host ranges, this time there are no
# leading 0s:

## db-[99:101]-node.example.com

Home - Category