# EC2 server recovery

## <span class="mw-headline" id="bkmrk-recovery-procedure-w-1">Recovery procedure without database backup</span>

#### <span class="mw-headline" id="bkmrk-changes-in-aws-1">Changes in AWS</span>

1. Make a snapshot of the running server
2. Make a volume from the snap shot
3. Name the volume: RESTORE COPY
4. Create a NEW server
5. Attatch the RESTORE COPY to NEW server on /dev/sdf

#### <span class="mw-headline" id="bkmrk-connect-to-new-serve-1">Connect to new server</span>

1. Install TS client tools
2. ts quick-install
3. ts stop-webserver
4. ts stop-database
5. mkdir /mnt/oldroot
6. sudo mount /dev/nvme1n1p1 /mnt/oldroot
7. sudo rm -r /var/lib/mysql
8. sudo cp -r /mnt/oldroot/var/lib/mysql /var/lib
9. ts start-database
10. mysql -uroot -p -e "UPDATE applive.systempolicy SET PolicyValue='false' WHERE PolicyName LIKE 'securitySsl%'"
11. sudo rm -r /mnt/sda/\*
12. sudo cp -r /mnt/oldroot/usr/tempusserva/sda/\* /mnt/sda/
13. sudo chmod 777 -R /mnt/sda/files
14. sudo cp /mnt/oldroot/usr/share/tomcat8/conf/Catalina/localhost/\* /usr/share/tomcat8/conf/Catalina/localhost
15. ts start-webserver
16. Ensure server is running

#### <span class="mw-headline" id="bkmrk-changes-in-aws-3">Changes in AWS</span>

1. Stop NEW server
2. Detatch RESTORE COPY
3. Stop OLD server
4. Deassociate IP from OLD server
5. Associate IP to NEW server
6. Start NEW server

#### <span class="mw-headline" id="bkmrk-connect-to-new-serve-3">Connect to new server</span>

1. ts install-ssl
2. mysql -uroot -p -e "UPDATE applive.systempolicy SET PolicyValue='true' WHERE PolicyName LIKE 'securitySsl%'"
3. ts restart-webserver

#### <span class="mw-headline" id="bkmrk-steps-is-using-s3-fi-1">Steps is using S3 filesystem</span>

1. [Server\_maintenence#Moving\_files\_to\_S3\_storage](https://docs.tsnocode.com/books/server-maintenence/page/moving-files-to-s3-storage)
    - Step: Add IAM role to server
    - Step: Install the mountpoint