Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The requested snapshot version is too old #96

Open
matthias-glatthorn opened this issue Mar 5, 2021 · 6 comments
Open

The requested snapshot version is too old #96

matthias-glatthorn opened this issue Mar 5, 2021 · 6 comments

Comments

@matthias-glatthorn
Copy link

I try to export a large collection. The code I use, to do the export looks like this:

firestoreService.initializeApp(serviceAccount);
const collectionToExport = 'intensityDetails';

firestoreService
    .backup(collectionToExport)
    .then(
        (data) => {
            console.log(Object.keys(data[collectionToExport]).length);
            fs.writeFileSync(collectionToExport + '.json', JSON.stringify(data));
        });

When I run the export, I get this error message:

FAILED_PRECONDITION: The requested snapshot version is too old.

Is there any solution to this?

@dalenguyen
Copy link
Owner

Hi @theoreticalsampling, can you create a test collection and check if it works.

@matthias-glatthorn
Copy link
Author

@dalenguyen Hi

I did that. I exported some collections from the same firebase project without any problems. But I can't export this large collection, due to this error.

@dalenguyen
Copy link
Owner

I think the process took too long. Then your snapshot expires before returning the result.

If the backlog in the subscription is too old -- and the resulting snapshot would expire in less than 1 hour -- then FAILED_PRECONDITION

https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.snapshots/create

@matthias-glatthorn
Copy link
Author

That's quite possible ... but how cloud I solve this problem? Is there any way, I could only export a specific range of the collection?

@dalenguyen
Copy link
Owner

You can try to add query to the backup script.

const queryByName = (collectionRef) =>
  collectionRef.where('name', '==', 'Dale Nguyen').get()

const users = await backup('users', {
  queryCollection: queryByName,
})

@thetinshusasi
Copy link

thetinshusasi commented Apr 5, 2021

You can try to add query to the backup script.

const queryByName = (collectionRef) =>
  collectionRef.where('id', '==', 'valid id').get()

const users = await backup('users', {
  queryCollection: queryByName,
})

This also fails when u try to iterate over a set of id

`
async function cleanExportByPropertyId (propertyId, firestoreService, fs){
const queryByName = (collectionRef) => collectionRef.where('property', '==', propertyId).get();

const cleans = await firestoreService.backup('cleans', {
	queryCollection: queryByName,
  });

 const data = JSON.stringify(cleans);
 const success =  await fs.writeFile(`./prodBackup/cleans-${propertyId}.json`, data, (err) => {
	 	if (err) throw err;
			console.log('Data written to file');
		});

		return success;

}

const propertyIds = [{
id: "ff31f5f5-28fa-480e-95fe-365ee7b1203f"
}];

const promiseArr =[];
for (const {id} of propertyIds) {
promiseArr.push(cleanExportByPropertyId(id, firestoreService, fs));

}

const res = await Promise.all(promiseArr);
console.log(res)

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants