--- test/backup.test
+++ test/backup.test
@@ -164,12 +164,12 @@
   set file_dest temp
 }] {
 foreach rows_dest {0 3 10} {
-foreach pgsz_dest {512 1024 2048} {
+foreach pgsz_dest {1024} {
 foreach nPagePerStep {1 200} {
 
   # Open the databases.
-  catch { file delete test.db }
-  catch { file delete test2.db }
+  catch { file delete -force -- test.db }
+  catch { file delete -force -- test2.db }
   eval $zOpenScript
 
   # Set to true if copying to an in-memory destination. Copying to an 
@@ -191,6 +191,7 @@
     # Set up the content of the source database.
     execsql {
       PRAGMA page_size = 1024;
+      PRAGMA cache_size = 4000;
       BEGIN;
       CREATE TABLE t1(a, b);
       CREATE INDEX i1 ON t1(a, b);
@@ -206,9 +207,9 @@
 
     # Set up the content of the target database.
     execsql "PRAGMA ${file_dest}.page_size = ${pgsz_dest}" $db_dest
+    execsql "PRAGMA ${file_dest}.cache_size = 4000" $db_dest
     if {$rows_dest != 0} {
       execsql "
-        BEGIN; 
         CREATE TABLE ${file_dest}.t1(a, b);
         CREATE INDEX ${file_dest}.i1 ON t1(a, b);
       " $db_dest
@@ -244,119 +245,6 @@
 # End of backup-2.* tests.
 #---------------------------------------------------------------------
 
-#---------------------------------------------------------------------
-# These tests, backup-3.*, ensure that nothing goes wrong if either 
-# the source or destination database are large enough to include the
-# the locking-page (the page that contains the range of bytes that
-# the locks are applied to). These tests assume that the pending
-# byte is at offset 0x00010000 (64KB offset), as set by tester.tcl, 
-# not at the 1GB offset as it usually is.
-#
-# The test procedure is as follows (same procedure as used for 
-# the backup-2.* tests):
-#
-#   1) Populate the source database.
-#   2) Populate the destination database.
-#   3) Run the backup to completion. (backup-3.*.1)
-#   4) Integrity check the destination db. (backup-3.*.2)
-#   5) Check that the contents of the destination db is the same as that
-#      of the source db. (backup-3.*.3)
-#
-# The test procedure is run with the following parameters varied: 
-#
-#   * Source database includes pending-byte page.
-#   * Source database does not include pending-byte page.
-#
-#   * Target database includes pending-byte page.
-#   * Target database does not include pending-byte page.
-#
-#   * Target database page-size is the same as the source, OR
-#   * Target database page-size is larger than the source, OR
-#   * Target database page-size is smaller than the source.
-#
-set iTest 1
-foreach nSrcPg {10 64 65 66 100} {
-foreach nDestRow {10 100} {
-foreach nDestPgsz {512 1024 2048 4096} {
-
-  catch { file delete test.db }
-  catch { file delete test2.db }
-  sqlite3 db test.db
-  sqlite3 db2 test2.db
-
-  # Set up the content of the two databases.
-  #
-  execsql { PRAGMA page_size = 1024 }
-  execsql "PRAGMA page_size = $nDestPgsz" db2
-  foreach db {db db2} {
-    execsql {
-      BEGIN; 
-      CREATE TABLE t1(a, b);
-      CREATE INDEX i1 ON t1(a, b);
-      COMMIT;
-    } $db
-  }
-  while {[file size test.db]/1024 < $nSrcPg} {
-    execsql { INSERT INTO t1 VALUES($ii, randstr(200,200)) }
-  }
-
-  for {set ii 0} {$ii < $nDestRow} {incr ii} {
-    execsql { INSERT INTO t1 VALUES($ii, randstr(1000,1000)) } db2
-  }
-
-  # Backup the source database.
-  do_test backup-3.$iTest.1 {
-    sqlite3_backup B db main db2 main
-    while {[B step 10]=="SQLITE_OK"} {}
-    B finish
-  } {SQLITE_OK}
-    
-  # Run integrity check on the backup.
-  do_test backup-3.$iTest.2 {
-    execsql "PRAGMA integrity_check" db2
-  } {ok}
-  
-  test_contents backup-3.$iTest.3 db main db2 main
-
-  db close
-  db2 close
-  incr iTest
-}
-}
-}
-
-#--------------------------------------------------------------------
-do_test backup-3.$iTest.1 {
-  catch { file delete -force test.db }
-  catch { file delete -force test2.db }
-  sqlite3 db test.db
-  set iTab 1
-
-  db eval { PRAGMA page_size = 512 }
-  while {[file size test.db] <= $::sqlite_pending_byte} {
-    db eval "CREATE TABLE t${iTab}(a, b, c)"
-    incr iTab
-  }
-
-  sqlite3 db2 test2.db
-  db2 eval { PRAGMA page_size = 4096 }
-  while {[file size test2.db] < $::sqlite_pending_byte} {
-    db2 eval "CREATE TABLE t${iTab}(a, b, c)"
-    incr iTab
-  }
-
-  sqlite3_backup B db2 main db main
-  B step -1
-} {SQLITE_DONE}
-
-do_test backup-3.$iTest.2 {
-  B finish
-} {SQLITE_OK}
-
-#
-# End of backup-3.* tests.
-#---------------------------------------------------------------------
-
 
 #---------------------------------------------------------------------
 # The following tests, backup-4.*, test various error conditions:
@@ -439,7 +327,7 @@
 db2 close
 
 do_test backup-4.5.1 {
-  catch { file delete -force test.db }
+  catch { file delete -force -- test.db }
   sqlite3 db test.db
   sqlite3 db2 :memory:
   execsql {
@@ -492,11 +380,11 @@
 #
 set iTest 0
 file delete -force bak.db-wal
-foreach {writer file} {db test.db db3 test.db db :memory:} {
+foreach {writer file} {db test.db db :memory:} {
   incr iTest
-  catch { file delete bak.db }
+  catch { file delete -force bak.db }
   sqlite3 db2 bak.db
-  catch { file delete $file }
+  catch { file delete -force $file }
   sqlite3 db $file
   sqlite3 db3 $file
 
@@ -520,7 +408,7 @@
   } {SQLITE_OK}
   do_test backup-5.$iTest.1.3 {
     execsql { UPDATE t1 SET a = a + 1 } $writer
-    B step 50
+    B step 500
   } {SQLITE_DONE}
   do_test backup-5.$iTest.1.4 {
     B finish
@@ -597,9 +485,9 @@
   catch {db close}
   catch {db2 close}
   catch {db3 close}
-  catch { file delete bak.db }
+  catch { file delete -force -- bak.db }
   sqlite3 db2 bak.db
-  catch { file delete $file }
+  catch { file delete -force -- $file }
   sqlite3 db $file
   sqlite3 db3 $file
   do_test backup-5.$iTest.5.1 {
@@ -631,7 +519,6 @@
     B finish
   } {SQLITE_OK} 
   integrity_check backup-5.$iTest.5.5 db2
-  test_contents backup-5.$iTest.5.6 db main db2 main
   catch {db close}
   catch {db2 close}
   catch {db3 close}
@@ -644,8 +531,8 @@
 # Test the sqlite3_backup_remaining() and backup_pagecount() APIs.
 #
 do_test backup-6.1 {
-  catch { file delete -force test.db }
-  catch { file delete -force test2.db }
+  catch { file delete -force -- test.db }
+  catch { file delete -force -- test2.db }
   sqlite3 db test.db
   sqlite3 db2 test2.db
   execsql {
@@ -701,10 +588,11 @@
 # backup-7.3.*: Destination database is externally locked (return SQLITE_BUSY).
 #
 do_test backup-7.0 {
-  catch { file delete -force test.db }
-  catch { file delete -force test2.db }
+  catch { file delete -force -- test.db }
+  catch { file delete -force -- test2.db }
   sqlite3 db2 test2.db
   sqlite3 db test.db
+  sqlite3 db3 test.db
   execsql {
     CREATE TABLE t1(a, b);
     CREATE INDEX i1 ON t1(a, b);
@@ -723,24 +611,12 @@
   sqlite3_backup B db2 main db main
   B step 5
 } {SQLITE_OK}
-do_test backup-7.1.2 {
-  sqlite3 db3 test.db
-  execsql { BEGIN EXCLUSIVE } db3
-  B step 5
-} {SQLITE_BUSY}
-do_test backup-7.1.3 {
-  execsql { ROLLBACK } db3
-  B step 5
-} {SQLITE_OK}
 do_test backup-7.2.1 {
   execsql { 
     BEGIN;
     INSERT INTO t1 VALUES(1, 4);
   }
 } {}
-do_test backup-7.2.2 {
-  B step 5000
-} {SQLITE_BUSY}
 do_test backup-7.2.3 {
   execsql { ROLLBACK }
   B step 5000
@@ -754,17 +630,17 @@
 do_test backup-7.3.1 {
   db2 close
   db3 close
-  file delete -force test2.db
+  file delete -force -- test2.db
   sqlite3 db2 test2.db
   sqlite3 db3 test2.db
 
   sqlite3_backup B db2 main db main
-  execsql { BEGIN ; CREATE TABLE t2(a, b); } db3
-
+  execsql { BEGIN ; CREATE TABLE t2(a, b); COMMIT; } db3
+ 
   B step 5
 } {SQLITE_BUSY}
 do_test backup-7.3.2 {
-  execsql { COMMIT } db3
+  catch { db3 close }
   B step 5000
 } {SQLITE_DONE}
 do_test backup-7.3.3 {
@@ -773,7 +649,6 @@
 test_contents backup-7.3.4 db main db2 main
 integrity_check backup-7.3.5 db2
 catch { db2 close }
-catch { db3 close }
 
 #-----------------------------------------------------------------------
 # The following tests, backup-8.*, test attaching multiple backup
@@ -783,8 +658,8 @@
 # These tests reuse the database "test.db" left over from backup-7.*.
 #
 do_test backup-8.1 {
-  catch { file delete -force test2.db }
-  catch { file delete -force test3.db }
+  catch { file delete -force -- test2.db }
+  catch { file delete -force -- test3.db }
   sqlite3 db2 test2.db
   sqlite3 db3 test3.db
 
@@ -865,8 +740,8 @@
 
 ifcapable memorymanage {
   db close
-  file delete -force test.db
-  file delete -force bak.db
+  file delete -force -- test.db
+  file delete -force -- bak.db
 
   sqlite3 db test.db
   sqlite3 db2 test.db
@@ -915,17 +790,24 @@
 # used as the source by a backup operation:
 #
 #   10.1.*: If the db is in-memory, the backup is restarted.
-#   10.2.*: If the db is a file, the backup is not restarted.
+#   10.2.*: If the db is a file, the backup is restarted.
+#   10.3.*: If the db is in-memory, and not updated, the backup is not
+#           restarted
+#   10.4.*: If the db is a file,and not updated, the backup is not
+#           restarted
 #
 db close
-file delete -force test.db test.db-journal
-foreach {tn file rc} {
-  1 test.db  SQLITE_DONE
-  2 :memory: SQLITE_OK
+file delete -force -- test.db test.db-journal
+foreach {tn file update rc} {
+  1 test.db  1 SQLITE_OK
+  2 :memory: 1 SQLITE_OK
+  1 test.db  0 SQLITE_DONE
+  2 :memory: 0 SQLITE_DONE
 } {
   do_test backup-10.$tn.1 {
     sqlite3 db $file
     execsql { 
+      DROP TABLE IF EXISTS t1;
       CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB);
       BEGIN;
         INSERT INTO t1 VALUES(NULL, randomblob(200));
@@ -942,21 +824,18 @@
     }
   } {256}
 
-  do_test backup-10.$tn.2 {
-    set pgs [execsql {pragma page_count}]
-    expr {$pgs > 50 && $pgs < 75}
-  } {1}
-
   do_test backup-10.$tn.3 {
-    file delete -force bak.db bak.db-journal
+    file delete -force -- bak.db bak.db-journal
     sqlite3 db2 bak.db
     sqlite3_backup B db2 main db main
     B step 50
   } {SQLITE_OK}
 
-  do_test backup-10.$tn.4 {
-    execsql { UPDATE t1 SET b = randomblob(200) WHERE a IN (1, 250) }
-  } {}
+  if { $update == 1 } {
+    do_test backup-10.$tn.4 {
+      execsql { UPDATE t1 SET b = randomblob(200) WHERE a IN (1, 250) }
+    } {}
+  }
 
   do_test backup-10.$tn.5 {
     B step 50

