Sybase supports two backup methods: one is to back up a single table and the other is to back up the entire database.
1. Single Table backup and recovery
You only need to use the BCP command enhanced by SYBASE:
BCP command format:
BCP database name .. table name in/out file name-USA-ppassword-s servername-C
Explanation:
Database Name: name of the database to be backed up
Name of the table to be backed up
In/out backup with out, recovery with in
File Name: indicates the backup file or the data file required for restoration. The file path information must be included.
Password: SA Password
Servername: If this machine is connected to multiple database servers, you must specify the corresponding database server.
2. backup and recovery of the entire database
This method is relatively complicated. You need to start the Sybase backup service before the backup. the startup method is as follows:
Startserver-F run_sybase // start the Sybase Service
Run_sybase:
#! /Bin/sh
#
# Master device path:/home/Sybase/data/Master
# Error Log Path:/home/Sybase/install/Sybase. Log
# Directory for shared memory files:/home/SYBASE
# Adaptive Server Name: Sybase
#
/Home/Sybase/bin/dataserver \
-D/home/Sybase/data/Master \
-E/home/Sybase/install/Sybase. log \
-M/home/SYBASE \
-Ssybase \
Startserver-F run_sybase_bak // start the Sybase backup service
Run_sybase_bak:
#! /Bin/sh
#
# Error Log Path:/home/Sybase/install/syb_backup.log
# Maximum number of network connections: 25
# Maximum number of server connections: 20
# Backup Server Name: syb_backup
#
/Home/Sybase/bin/backupserver \
-E/home/Sybase/install/syb_backup.log \
-N25 \
-C20 \
-Ssyb_backup \
Database Backup method:
Dump database name to path
Database restoration method:
Load database name from path
Before restoring the database, make sure that an empty database exists:
Disk init
Name = "physical device name ",
Physname = "/home/Sybase/data/AA. dat ",
Vdevno = 8, // use sp_helpdevice to check which no has been used
Size = 5120 (each unit is 2 K)
When creating a physical device, check whether the disk space is sufficient:
DF-K
Create Database database name on data name = 5120
After the database is restored, it is offline and must be manually online:
Online Database Name
Then add the Registration Name of Sybase and the username of the database:
Sp_addlogin "user", "password" // Add Registration
Go
Use Database Name
Go
Sp_adduser "user"
Go
How to view all tables in the database:
Select name from sysobjects where type = 'U'
To execute Sybase commands, you must first log on to Sybase
ISQL-USA-P