One perforce server backup
Perforce server has a checkpoint mechanism to back up the database of the server. Checkpoint, versioned files, Journal (only the server operation after the last checkpoint) is to restore all the items of the perforce server.
We create Checkpoints every night and back up versioned files. Just in case we need to save several checkpoints. The following is a script to back up the checkpoint and journal of the perforce server on Linux:
#! /Bin/bash
Backup_dir =/home/P4/backup
Depot_dir =/home/P4/srvroot
P4 =/opt/P4/P4
Host = P4: 1666
User = root
Password = Password
Days_to_keep = 3# Verify the depot
$ P4-p $ host-U $ user-p $ password verify-Q //... >/Dev/null
$ P4-p $ host-U $ user-p $ password verify-u-Q //... >/Dev/null 2>/dev/null
# Take a checkpoint
$ P4-p $ host-U $ user-p $ password admin checkpoint>/dev/null
# Move all journal and checkpoint files to the backup folder
MV $ depot_dir/Journal. * $ backup_dir
MV $ depot_dir/checkpoint. * $ backup_dir
# Remove Old checkpoint and journal files
Find $ backup_dir/Journal. *-mtime + $ days_to_keep-exec Rm-F {}\;>/dev/null 2>/dev/null
Find $ backup_dir/checkpoint. *-mtime + $ days_to_keep-exec Rm-F {}\;>/dev/null 2>/dev/null
2. Optimization of perforce Server
The perforce server slows down after running for a period of time and can be optimized by re-importing the checkpoint.
To optimize the perforce server. You need to create a checkpoint, stop the server, use the checkpoint to recover, and then start the server.
The following script is used to optimize the perforce server: # This script describes a way of optimizing and cleaning the metadata for a perforce Server
# The following steps are copied from the following URL:
#? Http://blog.perforce.com/blog? P = 187>
#? Stop your server
#? Take a checkpoint
#? Move your existing dB files to a save directory
#? Recover from the checkpoint
#? Check for errors during restore
#? Restart your server
#? Delete the files from the Save directory
# Instead of deleting the old database files immediately after the process, we
# Delete them during the next run instead.
Backup_dir =/home/P4/backup
Depot_dir =/home/P4/srvroot
P4d =/opt/P4/p4d
LOG_FILE =/var/log/p4d-error
#? Take a checkpoint
Echo "taking a checkpoint... "
/Opt/scripts/p4d/makecheckpoint. Sh
#? Stop your server
Echo "Stopping the perforce server... "
/Etc/init. d/p4d stop
#? Delete the files from the Save directory
Echo "backing up current database... "
Rm-r $ backup_dir/DB
#? Move your existing dB files to a save directory
Mkdir $ backup_dir/DB
MV $ depot_dir/DB. * $ backup_dir/DB/
#? Recover from the checkpoint
Checkpoint_file = 'LS-H-Sort = time $ backup_dir/checkpoint * | head-1'
Echo "do you wish to restore from checkpoint '$ checkpoint_file '? "
Select YN in "yes" "no"; do
Case $ YN in
Yes) echo "restoring checkpoint... "; Su P4-c" $ p4d-r $ depot_dir-L $ LOG_FILE-Jr $ checkpoint_file "; break ;;
No) echo "optimization aborted; restoring previous database... "; MV $ backup_dir/db. * $ depot_dir/; break ;;
Esac
Done
#? Restart your server
/Etc/init. d/p4d start
3. Use off-line perforce server for backup to reduce the downtime of main server
1) manually create off-line perforce Server
Cd c: \ p4root
P4d-R c: \ p4root-JC
Copy c: \ p4root \ checkpoint. nnn d: \ offline_p4root \ checkpoint. NNN
P4d-r d: \ offline_p4root-Jr checkpoint. NNN
2) perform journal on the main server every day, apply the old journal to the off-line perforce server, create a checkpoint for the off-line perforce server, and back up the checkpoint, this achieves the role of main server backup.
P4d-R c: \ p4root-jj d: \ offline_p4root \ truncated \ Journal
P4d-r d: \ offline_p4root-Jr. \ truncated \ journal. JNL. xxx
P4d-r d: \ offline_p4root-JD checkpoint. mmddyyyy
Note: At this time, journal uses the-JJ parameter (-Jr cannot be used), indicating that no checkpoint is created, but the current Journal is saved as journal. XXX, and then create a new journal file to record new operations. Because no checkpoint is created, mainserver does not need to be locked at this time.
3) from Versions later than 2010.2, we can create a replicated server (including Replicated Database [metadata] And versioned files) as a backup server for off-line, this reduces the lock time on the main server. At the same time, the replicated server can also be used as a read-only server to reduce the load on the main server, or as a hot backup of the main server. When the main server is down, the replicated server is started directly.
Refer:
Http://blogs.encodo.ch/news/view_folder.php? Id = 14 http://kb.perforce.com/article/126/offline-checkpoints
Complete!